简体   繁体   中英

How to link library into shared object with G++/LD

I am working on a C++ project which will be compiled to a shared object file. It needs to have access to the python interpreter, which is where I reach my hurdle: upon linking, I receive /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginT.o: relocation R_X86_64_32 against hidden symbol '__TMC_END__' can not be used when making a shared object (The opening quotation on __TMC_END__ was a backtick, but this ruined the formatting so I changed it, if this is useful information).

The obvious solution is to download the Python source and compile it along with my code, but I would rather not complicate my development workflow to this point, thus, my question is: how do I embed the Python interpreter in my shared object file?

I am on Ubuntu 20.04 with a full Python 3.9 install, and access to all development files.

(My apologies if this is the wrong site)

It appears that my problem was solved by adding the python lib to the g++ shared-object-builder command. I previously only added it to the first phase of compilation (convert into an object file).

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