If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > C prog compilation error on AIX using Gcc

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-14-08, 13:19
UDBStudent UDBStudent is offline
Registered User
 
Join Date: Feb 2008
Posts: 6
C prog compilation error on AIX using Gcc

Hi,

I am trying to compile a C prog. which I found on the internet
using GCC compiler.

Can anybody help me ?

Thanks,

I get the following error message:


In file included from myprogram.c:20:
/opt/IBM/db2/V9.1/include/sqladef.h:38: warning: ignoring #pragma options align
/opt/IBM/db2/V9.1/include/sqladef.h:230: warning: ignoring #pragma options align
In file included from myprogram.sqc:24:
/opt/IBM/db2/V9.1/include/sqlca.h:33: warning: ignoring #pragma options align
/opt/IBM/db2/V9.1/include/sqlca.h:116: warning: ignoring #pragma options align
myprogram.sqc:27: warning: return type of 'main' is not 'int'
ld: 0706-005 Cannot find or open file:
ldpen(): A file or directory in the path name does not exist.
collect2: ld returned 255 exit status
Reply With Quote
  #2 (permalink)  
Old 04-15-08, 05:53
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The code seems to be crappy - "main" returns "int" for decades already, but some folks still do it wrong and use "void". I would be very, very careful using it. Who knows what else is wrong?

Besides that, you have a linker issue, not a compiler problem. There are a bunch of warnings that you can ignore. When linking everything into an executable, something is missing. You should show us the exact commands that you try to use...
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 04-15-08, 13:33
UDBStudent UDBStudent is offline
Registered User
 
Join Date: Feb 2008
Posts: 6
Hello there,
After I had done my post here I realized that the main() should be returning int and not void. I have corrected that... Thanks for pointing it too..
I have used the following command to compile it and was able to get a.out

Thanks in advance.



gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
-L/database1/db2home/db2inst3/sqllib/lib \
-ldb2

But following command gives errors :

gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
-L/database1/db2home/db2inst3/sqllib/lib \
-ldb2
-Wl,-rpath, /opt/IBM/db2/V9.1
Reply With Quote
  #4 (permalink)  
Old 04-15-08, 17:38
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by UDBStudent
But following command gives errors :
gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
-L/database1/db2home/db2inst3/sqllib/lib \
-ldb2
-Wl,-rpath, /opt/IBM/db2/V9.1
Just leave out the rpath, and set LD_LIBRARY_PATH to /opt/IBM/db2/V9.1
Or maybe this is not even necessary; depends on the platform.
If I'm not mistaken this only works on Solaris, and is only needed if the db2 library is a shared lib (db2.so), not if it's a static one (db2.a).
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #5 (permalink)  
Old 04-16-08, 03:47
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by UDBStudent
gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
-L/database1/db2home/db2inst3/sqllib/lib \
-ldb2

But following command gives errors :

gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
-L/database1/db2home/db2inst3/sqllib/lib \
-ldb2
-Wl,-rpath, /opt/IBM/db2/V9.1
Do you have a space between "-Wl,-rpath," and "/opt/IBM/db2/V9.1"? If so, you should remove this. Otherwise, you are adding and empty path to the linker search path and the linker has no idea what to do with the "/opt/IBM/db2/V9.1" because it is a directory and not a file.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #6 (permalink)  
Old 04-16-08, 09:16
UDBStudent UDBStudent is offline
Registered User
 
Join Date: Feb 2008
Posts: 6
Thanks a lot guys for your immense help.
I was able to solve the problem with dropping off the
-Wl,-rpath, /opt/IBM/db2/V9.1

Thanks,
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On