我在我的OpenSUSE上發佈了一段C++軟件,我喜歡在另一個OpenSUSE系統上進行測試。如何通過g ++編譯獨立的可執行文件?
我複製了其他系統上的可執行文件,但是當我開始它,我收到一個錯誤:
"error while loading shared libraries: libboost_system.so.1.61.0: cannot open shared object file: No such file or directory"
我怎麼能編譯不依賴一個獨立的可執行文件?
Eclipse一樣,這樣的:
17:24:41 **** Incremental Build of configuration Debug for project boostServer ****
make all
Building file: ../src/boostCom.cpp
Invoking: Cross G++ Compiler
g++ -I/opt/boost -I/usr/local/lib -O0 -g3 -Wall -c -fmessage-length=0 -isystem /opt/boost -MMD -MP -MF"src/boostCom.d" -MT"src/boostCom.o" -o "src/boostCom.o" "../src/boostCom.cpp"
Finished building: ../src/boostCom.cpp
Building file: ../src/main.cpp
Invoking: Cross G++ Compiler
g++ -I/opt/boost -I/usr/local/lib -O0 -g3 -Wall -c -fmessage-length=0 -isystem /opt/boost -MMD -MP -MF"src/main.d" -MT"src/main.o" -o "src/main.o" "../src/main.cpp"
Finished building: ../src/main.cpp
Building target: boostServer
Invoking: Cross G++ Linker
g++ -L/usr/local/lib -o "boostServer" ./src/boostCom.o ./src/boostServer.o ./src/main.o -lboost_system -lboost_serialization -lboost_thread -lboost_date_time -lpthread
Finished building target: boostServer
電賀烏爾夫
您可能會使用靜態鏈接。 –
@Ulf在鏈接g ++中使用'-static'。 (即列表中的最後一個),那麼,如果有靜態庫,它會優先選擇opon共享的。 – SHR