2010-06-21 21 views
19

derleme gibi, ama 100+ hataları elde ederken:C++ hatalar Ben bir oyun derlemek çalışıyorum

C:\Users\AppData\Local\Temp\cctQCagR.o: In function `load_image(std::string)': 
main.cpp:(.text+0x4bd4): undefined reference to `std::string::c_str() const' 
C:\Users\Bill\AppData\Local\Temp\cctQCagR.o: In function `createShip(float, float)': 
main.cpp:(.text+0x4da4): undefined reference to `std::allocator<char>::allocator()' 
main.cpp:(.text+0x4dbc): undefined reference to `std::basic_string<char, std::char_tra 
its<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> cons 
t&)' 
main.cpp:(.text+0x4de4): undefined reference to `std::basic_string<char, std::char_tra 
its<char>, std::allocator<char> >::~basic_string()' 
main.cpp:(.text+0x4e04): undefined reference to `std::basic_string<char, std::char_tra 
its<char>, std::allocator<char> >::~basic_string()' 
main.cpp:(.text+0x4e1c): undefined reference to `std::allocator<char>::~allocator()' 
main.cpp:(.text+0x4e28): undefined reference to `std::allocator<char>::allocator()' 
main.cpp:(.text+0x4e40): undefined reference to `std::basic_string<char, std::char_tra 
its<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> cons 
t&)' 
main.cpp:(.text+0x4e60): undefined reference to `std::allocator<char>::~allocator()' 
main.cpp:(.text+0x4e70): undefined reference to `__cxa_end_cleanup' 
main.cpp:(.text+0x4e98): undefined reference to `std::basic_string<char, std::char_tra 
its<char>, std::allocator<char> >::~basic_string()' 
main.cpp:(.text+0x4eb8): undefined reference to `std::basic_string<char, std::char_tra 
its<char>, std::allocator<char> >::~basic_string()' 
main.cpp:(.text+0x4ed0): undefined reference to `std::allocator<char>::~allocator()' 
main.cpp:(.text+0x4ef4): undefined reference to `std::allocator<char>::~allocator()' 
main.cpp:(.text+0x4f04): undefined reference to `__cxa_end_cleanup' 
C:\Users\Bill\AppData\Local\Temp\cctQCagR.o: In function `load_files()': 
main.cpp:(.text+0x5164): undefined reference to `std::allocator<char>::allocator()' 
main.cpp:(.text+0x517c): undefined reference to `std::basic_string<char, std::char_tra 
its<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> cons 
t&)' 
+1

C++ standart kitaplığınıza karşı bağlantı oluşturuyorsunuz değil mi? –

+0

Derlemek için kullandığınız komutu yapıştırabilir misiniz? – Anthony

+0

Kullanma: arm-none-linux-gnueabi-gcc ............ –

cevap

55

ben yerine ++ g gcc ile main.cpp derlemeye çalışıyoruz inanıyoruz.

#include <string> 
#include <stdio.h> 
int main() 
{ 
    std::string bla; 
    bla = "BLA BLA"; 
    printf("%s\n",bla.c_str()); 
    return 0; 
} 

Yukarıdaki kod snippet'ini gcc ile oluşturursanız, belirttiğiniz hataları alırsınız. Eğer g ++ kullanırsanız, tamam, bu, mantıklıdır, çünkü g ++, C++ oluştururken bir araya getirilen tüm uygun şeyleri sağlayacaktır.

+0

gcc'nin dışarıda bırakılması ne anlama geliyor? –

18

İkilinizi libstdC++ ile ilişkilendirmeniz gerekir. Gcc kullanıyorsanız, bunu açıkça komut satırında belirtmeniz gerekir. gcc -lstdc++ tmp.cpp
g ++ kullanılıyorsa, libstdC++ varsayılan olarak bağlanacaktır.
g++ tmp.cpp

İlgili konular