2014-09-04 51 views
1

我剛剛得到這個錯誤,當我試圖以內在我的Ubuntu創建一個共享庫14.04 64位系統轉儲:核心,同時創造共享庫

g++ -Wall -g -Iinclude -c /home/pure/Schreibtisch/TestDLL/src/test.cpp -o obj/Debug/src/test.o 

g++ -shared obj/Debug/src/test.o -o bin/Debug/TestDLL.so 
collect2: error: ld terminated with signal 6 [Abgebrochen], core dumped 
/usr/bin/ld: ld: wcsrtombs.c:99: __wcsrtombs: Zusicherung »data.__outbuf[-1] == '\0'« nicht erfüllt. 

我也試着從一個簡單的做一個簡單的共享庫有一個空的構造函數和一個空的析構函數的類,同樣的錯誤來了。

任何人都可以幫助我如何解決這個問題嗎? 如果需要更多信息,我可以告訴他們。

純@純QOSMIO-X500:〜$其中g ++

/usr/bin/g++

純@純QOSMIO-X500:〜$克++ --version

g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

這:

LC_ALL=C g++ -shared /home/pure/Schreibtisch/TestDLL/obj/Debug/src/test.o -o /home/pure/Schreibtisch/TestDLL/libTestDLL.so

現在返回:

/usr/bin/ld: /home/pure/Schreibtisch/TestDLL/obj/Debug/src/test.o: relocation R_X86_64_32S against `_ZTV4test' can not be used when making a shared object; recompile with -fPIC /home/pure/Schreibtisch/TestDLL/obj/Debug/src/test.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status

+0

用'gdb'分析核心文件。 – 0x499602D2 2014-09-04 12:18:38

+0

嘗試在英文系統上構建相同的源代碼。 – 2014-09-04 12:18:59

+0

是的,在開始編譯過程之前,請做一些類似導出LC_ALL = C(或者類似的命令)。 – 2014-09-04 12:21:32

回答

1

/usr/bin/ld: /home/pure/Schreibtisch/TestDLL/obj/Debug/src/test.o: relocation R_X86_64_32S against `_ZTV4test' can not be used when making a shared object; recompile with -fPIC /home/pure/Schreibtisch/TestDLL/obj/Debug/src/test.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status

我不知道爲什麼你的本地語言環境(德語)崩潰並且使用默認語言環境有用的錯誤消息。但是,現在鏈接器本身告訴你什麼是錯誤的:你沒有用-fPIC編譯你的目標代碼。

PIC代表位置無關代碼並且因爲它們在存儲器位置事先不知道是必要的共享庫。例如,使用-fPIC生成的代碼使用相對而非絕對地址進行跳轉。

+0

明白了,沒有錯誤,編譯並獲得共享庫吧!謝謝! – PuRe 2014-09-04 13:57:14