我一直在努力将我的一个游戏移植到Linux上,似乎无法弄清楚我收到错误的原因.该游戏最初是在Visual Studio 2010中编写的,我已经提取了所有需要的内容(标题,cpp,纹理),并且我正在尝试编译.
使用g++ -c -o exampleFile.o exampleFile.cpp工作正常编译文件没有任何错误.但是在链接时,我遇到了关于std函数的数百个错误,例如:
Bmp.o: In function `Image::Bmp::Bmp()':
Bmp.cpp:(.text+0x58): undefined reference to `std::allocator<char>::allocator()'
Bmp.cpp:(.text+0x74): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
Bmp.cpp:(.text+0x80): undefined reference to `std::allocator<char>::~allocator()'
Bmp.cpp:(.text+0x91): undefined reference to `std::allocator<char>::~allocator()'
Run Code Online (Sandbox Code Playgroud)
可以在PasteBin上找到完整输出
该Bmp.cpp文件是由其他人编写的库函数,可以在这里找到.上面提到的代码是:
#include <fstream>
#include <iostream>
#include <cstring>
#include "Bmp.h"
using std::ifstream;
using std::ofstream;
using std::ios;
using std::cout;
using std::endl;
using namespace Image;
///////////////////////////////////////////////////////////////////////////////
// default constructor
///////////////////////////////////////////////////////////////////////////////
Bmp::Bmp() : width(0), height(0), bitCount(0), dataSize(0), …Run Code Online (Sandbox Code Playgroud)