1
我只是想做一個矢量,但它給了我一個巨大的錯誤,我正在從我的其他項目中看到一個工作示例。代碼:當初始化矢量時出現令人討厭的錯誤
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
struct organism {
bool One;
bool Two;
};
std::vector<organism> organisms;
int main() {
printf("Content-type: text/html\n\n");
printf("TEST");
printf(getenv("QUERY_STRING"));
return 0;
}
錯誤:
> "make"
C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp
C:\Users\Stephen\AppData\Local\Temp\ccc0a0w2.o:main.cpp:(.text$_ZN9__gnu_cxx13new_allocatorI8organismE10deallocateEPS1_j[__gnu_cxx::new_allocator<organism>::deallocate(organism*, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
C:\Users\Stephen\AppData\Local\Temp\ccc0a0w2.o:main.cpp:(.eh_frame$_ZNSt12_Vector_baseI8organismSaIS0_EED2Ev+0x13): undefined reference to `__gxx_personality_v0'
C:\Users\Stephen\AppData\Local\Temp\ccc0a0w2.o:main.cpp:(.eh_frame$_ZNSt6vectorI8organismSaIS0_EED1Ev+0x13): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
"make": *** [build] Error 1
> Process Exit Code: 2
> Time Taken: 00:01
我可以編譯它,如果我註釋掉std::vector<organism> organisms;
,但我不知道什麼是錯線。在我的其他項目中完全一樣,編譯得很好。
Damnit。我只是用gcc而不是g ++編譯來解決另一個問題;也就是說,g ++不適用於CGI/Apache。 – 2012-03-25 03:21:00
也許你應該問一個單獨的問題。 :) – 2012-03-25 03:21:34
你也可以用'gcc'進行編譯,但是可以通過'-lstdC++'作爲選項(以獲得正確鏈接的C++庫):'gcc -o build/e2.exe source/main.cpp -lstdC++'。 – 2012-05-25 19:20:13