LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   g++ vs clang++: odd behavious (https://www.linuxquestions.org/questions/programming-9/g-vs-clang-odd-behavious-4175456020/)

miguelg 03-29-2013 07:38 AM

g++ vs clang++: odd behavious
 
Hello Forum,

I'm come across a very strange issue affecting GCC.

If I compile an SO using g++ [0] the library dependencies are totally different than when compiling the same SO with clang++ [1] using the exact same parameters.

I imagine it's something to do with parameter order; can an enlightened guru please shed some light on this?


[0] http://pastebin.com/8Xp9mwwA
[1] http://pastebin.com/xM8NNj4m

pan64 03-29-2013 07:50 AM

I would assume g++ detected those libs are not required, therefore dropped (for example -lpthread).

miguelg 03-29-2013 08:09 AM

Quote:

Originally Posted by pan64 (Post 4921066)
I would assume g++ detected those libs are not required, therefore dropped (for example -lpthread).

But the problem is when I run the g++ compiled program it fails due to an undefined symbol (not so with the clang++ version):

out/src/omnis: symbol lookup error: /home/guedesm/prj/omnis/sh/../out/sources/clank/libclank.so: undefined symbol: clang_createIndex


So if the case is it is dropping some libs then it is doing so in error.

Could it be some other reason perhaps?

NevemTeve 03-29-2013 11:56 AM

My guess is that libomnis.a is completely left out from the shared object.

Perhaps:

Code:

... -o libclank.so objects_modules -Wl,-whole-archive libomnis.a -Wl,-no-whole-archive ...
PS: I think using libtool wouldn't be a bad idea.

Sergei Steshenko 03-30-2013 03:59 PM

Quote:

Originally Posted by belnac (Post 4921060)
Hello Forum,

I'm come across a very strange issue affecting GCC.

If I compile an SO using g++ [0] the library dependencies are totally different than when compiling the same SO with clang++ [1] using the exact same parameters.

I imagine it's something to do with parameter order; can an enlightened guru please shed some light on this?


[0] http://pastebin.com/8Xp9mwwA
[1] http://pastebin.com/xM8NNj4m

AFAIK, g++ and clang++ each uses its own standard C++ library coming with each of the compilers.


All times are GMT -5. The time now is 02:53 AM.