Letakkan perpustakaan di bagian akhir:
g++ -I /home/username/local/include -L /home/username/local/lib main.cpp person.pb.cc -lprotobuf -pthread
Dari Opsi Tautan GCC:
-llibrary -l library Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.) It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, `foo.o -lz bar.o' searches library `z' after file foo.o but before bar.o. If bar.o refers to functions in `z', those functions may not be loaded.
Juga, gunakan -pthread
bukannya -lpthread
sebagai -pthread
dapat menyetel tanda untuk preprocessor dan linker.
Bendera penautan pustaka berada di akhir argumen kompiler:
g++ -I /home/username/local/include -L /home/username/local/libmain.cpp person.pb.cc -lprotobuf -lpthread
Bagaimana cara mengkompilasi pustaka standar glibc C saya sendiri dari sumber dan menggunakannya?
Cara menampilkan hanya baris yang berbeda menggunakan diff (bash)