简体   繁体   中英

warning: cannot find entry symbol _start - while compiling to .so

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!

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.

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.

使用Intel编译器编译为目标文件,然后使用gcc链接目标文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM