最近我需要在Ubuntu上編程時使用zlib,在這裏我有一個問題。 我寫了一個小程序來測試zlib函數,並在Eclipse中構建它。 我發現它可以被編譯,但也有一些鏈接錯誤是這樣的:關於在Ubuntu的zlib鏈接錯誤
main.cpp:27: undefined reference to `compress'
main.cpp:38: undefined reference to `uncompress'
我應該怎樣做呢?如果這是因爲沒有庫文件?
任何人都可以提供一些幫助嗎?非常感謝!
MOODY_Y
另外,這裏有我的建築信息:
11:59:08 **** Build of configuration Debug for project test_zlib ****
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Finished building: ../main.cpp
Building target: test_zlib
Invoking: GCC C++ Linker
g++ -o "test_zlib" ./main.o
./main.o: In function `main':
/home/hyq/workspace/test_zlib/Debug/../main.cpp:27: undefined reference to `compress'
/home/hyq/workspace/test_zlib/Debug/../main.cpp:38: undefined reference to `uncompress'
collect2: ld return 1
make: *** [test_zlib] error 1
11:59:10 Build Finished (took 1s.715ms)
顯示您的鏈接器命令鏈接YOUE源zlib.Build你的代碼。 –
你鏈接到zlib了嗎? – trojanfoe
正如我所說的,我只是使用Eclipse IDE來構建它,這裏是鏈接器命令:g ++ -o「test_zlib」./main.o –