问题
Hello I am running Linux Ubuntu and am compiling using icpc (intel compiler), I want to get a shared library so I used the command:
icpc -o myShared.so -std=c++11 -shared -DSTDC_HEADERS -D __cplusplus=201103L -fpermissive -DPT_XX_DEV -fexceptions -frtti -DANDROID -w -fstack-protector -fPIE -fPIC -pie -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -I/home/admins/aaa/include -I/home/admins/bbb/include a.cpp b.cpp c.cpp -lpthread -L./../../static_libs -lmyStatic
I an getting a warning:
ld: warning: cannot find entry symbol _start; defaulting to 0000000000007040
I read about this warning in previous topics, and I discovered that this warning connected to the entry point of the program, but as far as I understand - there shouldn't be entry point in shared library.
Does Anyone have an idea how to resolve it?
Thank you very much!
回答1:
add the following line during compilation. This might solve your problem.
-lc --entry main
-lc tells the compiler to use the standard C library and --entry main tells the compiler to use the address of 'main' as the application's entry point.
Note: Though I am not familiar with intel compiler still I gave a try.
回答2:
Removing -fPIE and -pie flags solved my problem. -pie shouldn't be used when you are trying to create shared library, and also -fPIE shouldn't be used in most of the cases.
回答3:
Compile to object files with the Intel compiler, then link the object files using gcc
.
来源:https://stackoverflow.com/questions/33636471/warning-cannot-find-entry-symbol-start-while-compiling-to-so