By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,368 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,368 IT Pros & Developers. It's quick & easy.

errors while creating a dll using gcc

P: 27
hi.. i am creating a .dll file from an object file using gcc... i want to create a shared library... i want to use the dll to implement a new functionality.. but when i compile the file for creating the dll i get the following errors..

Cannot export .idata$4: symbol not found
Cannot export .idata$5: symbol not found
Cannot export .idata$6: symbol not found
Cannot export .text: symbol not found
Cannot export ⌂postgres_NULL_THUNK_DATA: symbol not found
collect2: ld returned 1 exit status


i used the following statement to create the dll....



C:\MinGW\bin>gcc -shared -o xpath2.dll xpath2.o -L "C:/Program Files/PostgreSQL
8.3/lib" -lpostgres -lxml2


how can i sort this problem.. please help.. thanks in advance
May 28 '08 #1
Share this Question
Share on Google+
5 Replies


100+
P: 424
That is a link-time error (generated by the linker: "ld"), they can be hard to debug. The linker is complaining that some of the symbols referenced in object files or libraries are not present: For example, if your main routine written in main.c calls functions defined in somefile.c, you can compile main.c and somefile.c individually into main.o and somefile.o:

gcc -c main.c -o main.o
gcc -c somefile.c -o somefile.o

Then you link main.o and somefile.o together to make the executable. If you forget to link in somefile.o, you will get this type of error because some symbols in somefile.o referred to in main.o are not present:

gcc main.o somefile.o -o main.exe <-- Good!
gcc main.o -o main.exe <-- linker errors: symbols in somefile.o not found!

It could be caused by any of the libraries you're linking, namely, the postgres and xml2 library. Maybe they're out of date? Or it could be that you're missing some libraries where those symbols are defined. Or it could be that there's some other c/cpp file, that you're forgetting to link in, like in the somefile.c example above.

Also, to catch errors earlier in the compilation process, enable all warnings with:
-Wall -Wpointer-arith -Wstrict-prototypes -Wwrite-strings -Wuninitialized
more info: gcc warning flags.

One last point, if you've declared any of your variables to have external linkage (by prefixing them with 'extern'), ensure that they're actually initialized somewhere.
May 28 '08 #2

P: 27
Thanks for the reply... the error is with the postgres lib i think.. should i change the library to which i am referrind to or anything else...
May 29 '08 #3

100+
P: 424
Well, that's hard to comment on, it depends on the specifics of your project. I suggest you comment out as much functionality as possible so that you can compile without errors, then gradually uncomment out more functionality until you isolate the error. Eventually you may be able to track down the error to some functions which you can fix or substitute, etc.
May 29 '08 #4

RRick
Expert 100+
P: 463
Your problem is not uncommon with creating dlls with gcc. The error message looks to be a generic one where (it appears) gcc doesn't understand the library you are passing.

I have found a couple of links about the problem. but unfortunately, no solution.

http://cygwin.com/ml/cygwin/2004-08/msg01118.html

http://forums.oracle.com/forums/thre...sageID=2171371

http://readlist.com/lists/lists.sour...rs/0/1248.html

If you really need to track down the problem, first try creating a test program instead of the dll. The test program should weed out the various library issues.
May 30 '08 #5

100+
P: 424
I must say that I've had my fair share of inexplicable problems using MinGW's port of gcc for windows with code that compiled and worked fine with gcc under linux. You'd be better off using a compiler specifically developed for windows. Since you can get VC++ express for free, I don't see why you would want to persevere with a ported *nix compiler.
May 30 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.