代码在Xcode中编译,但不是从命令行编译 p>所以我有一个迷你OpenGL项目,我在C++中用XCODEL做。我正在使用几个库,包括SOIL和GLEW库、它们各自的头文件以及SDL2、OpenGL和Corefoundation框架。该项目在XCODEL中构建良好,并具有以下编译器选项:C++语言方言设置为-STD= C++ 11和C++标准库,设置为LBC+++。但是,当我尝试在命令行上使用clang构建此项目时,请使用以下命令: clang++ -stdlib=libc++ -std=c++11 -I/usr/local/include/SOIL/src -I/usr/local/include/glm/glm -I/usr/local/include/glew-1.10.0/include/ -framework SDL2 -framework CoreFoundation -framework OpenGL -L/usr/local/include/glew-1.10.0/lib/ -L/usr/local/lib main.cpp euchre.cpp euchre.h (These 3 files are in the same directory)

代码在Xcode中编译,但不是从命令行编译 p>所以我有一个迷你OpenGL项目,我在C++中用XCODEL做。我正在使用几个库,包括SOIL和GLEW库、它们各自的头文件以及SDL2、OpenGL和Corefoundation框架。该项目在XCODEL中构建良好,并具有以下编译器选项:C++语言方言设置为-STD= C++ 11和C++标准库,设置为LBC+++。但是,当我尝试在命令行上使用clang构建此项目时,请使用以下命令: clang++ -stdlib=libc++ -std=c++11 -I/usr/local/include/SOIL/src -I/usr/local/include/glm/glm -I/usr/local/include/glew-1.10.0/include/ -framework SDL2 -framework CoreFoundation -framework OpenGL -L/usr/local/include/glew-1.10.0/lib/ -L/usr/local/lib main.cpp euchre.cpp euchre.h (These 3 files are in the same directory),c++,xcode,opengl,glew,soil,C++,Xcode,Opengl,Glew,Soil,我得到以下错误: Undefined symbols for architecture x86_64: "_SOIL_free_image_data", referenced from: Euchre::MakeObject::LoadTexture(char const*, int) in euchre-d6b330.o "_SOIL_load_image", referenced from: Euchre::MakeObject::LoadTexture(char const*, i

我得到以下错误:

Undefined symbols for architecture x86_64:
"_SOIL_free_image_data", referenced from:
  Euchre::MakeObject::LoadTexture(char const*, int) in euchre-d6b330.o
"_SOIL_load_image", referenced from:
  Euchre::MakeObject::LoadTexture(char const*, int) in euchre-d6b330.o
"___glewActiveTexture", referenced from:
  Euchre::MakeObject::LoadTexture(char const*, int) in euchre-d6b330.o
"___glewAttachShader", referenced from:
  Euchre::MakeObject::LoadShaders(char const*, char const*) in euchre-d6b330.o
"___glewBindBuffer", referenced from:
  Euchre::MakeObject::makeAttribute(unsigned int, char const*, unsigned int, unsigned int, int, unsigned int, unsigned char, int, void const*) in euchre-d6b330.o
  unsigned int Euchre::MakeObject::makeBufferObject<float>(int, unsigned int, unsigned int, std::__1::vector<float, std::__1::allocator<float> >) in euchre-d6b330.o
  unsigned int Euchre::MakeObject::makeBufferObject<unsigned int>(int, unsigned int, unsigned int, std::__1::vector<unsigned int, std::__1::allocator<unsigned int> >) in euchre-d6b330.o
"___glewBindVertexArray", referenced from:
  _main in main-6799fc.o
"___glewBufferData", referenced from:
  unsigned int Euchre::MakeObject::makeBufferObject<float>(int, unsigned int, unsigned int, std::__1::vector<float, std::__1::allocator<float> >) in euchre-d6b330.o
  unsigned int Euchre::MakeObject::makeBufferObject<unsigned int>(int, unsigned int, unsigned int, std::__1::vector<unsigned int, std::__1::allocator<unsigned int> >) in euchre-d6b330.o
"___glewCompileShader", referenced from:
  Euchre::MakeObject::compileShader(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in euchre-d6b330.o
"___glewCreateProgram", referenced from:
  Euchre::MakeObject::LoadShaders(char const*, char const*) in euchre-d6b330.o
"___glewCreateShader", referenced from:
  Euchre::MakeObject::LoadShaders(char const*, char const*) in euchre-d6b330.o
"___glewDeleteBuffers", referenced from:
  _main in main-6799fc.o
"___glewDeleteProgram", referenced from:
  _main in main-6799fc.o
"___glewDeleteShader", referenced from:
  Euchre::MakeObject::LoadShaders(char const*, char const*) in euchre-d6b330.o
"___glewDeleteVertexArrays", referenced from:
  _main in main-6799fc.o
"___glewEnableVertexAttribArray", referenced from:
  Euchre::MakeObject::makeAttribute(unsigned int, char const*, unsigned int, unsigned int, int, unsigned int, unsigned char, int, void const*) in euchre-d6b330.o
"___glewGenBuffers", referenced from:
  unsigned int Euchre::MakeObject::makeBufferObject<float>(int, unsigned int, unsigned int, std::__1::vector<float, std::__1::allocator<float> >) in euchre-d6b330.o
  unsigned int Euchre::MakeObject::makeBufferObject<unsigned int>(int, unsigned int, unsigned int, std::__1::vector<unsigned int, std::__1::allocator<unsigned int> >) in euchre-d6b330.o
"___glewGenVertexArrays", referenced from:
  Euchre::MakeObject::makeVertexArrayObject(int) in euchre-d6b330.o
"___glewGetAttribLocation", referenced from:
  Euchre::MakeObject::makeAttribute(unsigned int, char const*, unsigned int, unsigned int, int, unsigned int, unsigned char, int, void const*) in euchre-d6b330.o
"___glewGetShaderiv", referenced from:
  Euchre::MakeObject::compileShader(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in euchre-d6b330.o
"___glewLinkProgram", referenced from:
  Euchre::MakeObject::LoadShaders(char const*, char const*) in euchre-d6b330.o
"___glewShaderSource", referenced from:
  Euchre::MakeObject::compileShader(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in euchre-d6b330.o
"___glewUseProgram", referenced from:
  _main in main-6799fc.o
"___glewVertexAttribPointer", referenced from:
  Euchre::MakeObject::makeAttribute(unsigned int, char const*, unsigned int, unsigned int, int, unsigned int, unsigned char, int, void const*) in euchre-d6b330.o
"_glewExperimental", referenced from:
  _main in main-6799fc.o
"_glewInit", referenced from:
  _main in main-6799fc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
架构x86_64的未定义符号: “\u土壤\u自由\u图像\u数据”,参考自: Euchre-d6b330.o中的Euchre::MakeObject::LoadTexture(char const*,int) “土壤负荷图像”,参考自: Euchre-d6b330.o中的Euchre::MakeObject::LoadTexture(char const*,int) “uuuu_uuuglewactivetexture”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::LoadTexture(char const*,int) “glewAttachShader”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::LoadShader(char const*,char const*) “uuuu_uuuGlewbindBuffer”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::makeAttribute(无符号整数、字符常量*、无符号整数、无符号整数、整数、无符号整数、无符号字符、整数、无效常量*) Euchre-d6b330.o中的unsigned int Euchre::MakeObject::makeBufferObject(int,unsigned int,unsigned int,std:u 1::vector) Euchre-d6b330.o中的unsigned int Euchre::MakeObject::makeBufferObject(int,unsigned int,unsigned int,std:u 1::vector) “uuuu_uuuuGlewbindvertexarray”,引用自: _干管输入干管-6799fc.o “glewBufferData”,引用自: Euchre-d6b330.o中的unsigned int Euchre::MakeObject::makeBufferObject(int,unsigned int,unsigned int,std:u 1::vector) Euchre-d6b330.o中的unsigned int Euchre::MakeObject::makeBufferObject(int,unsigned int,unsigned int,std:u 1::vector) “glewCompileShader”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::compileShader(unsigned int,std:_1::basic_string const&) “glewCreateProgram”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::LoadShader(char const*,char const*) “uuuuuuuuu glewCreateShader”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::LoadShader(char const*,char const*) “glewDeleteBuffers”,引用自: _干管输入干管-6799fc.o “glewDeleteProgram”,引用自: _干管输入干管-6799fc.o “glewDeleteShader”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::LoadShader(char const*,char const*) “glewDeleteVertexArrays”,引用自: _干管输入干管-6799fc.o “\uuuuuuuuuu glewenablevertexattributearray”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::makeAttribute(无符号整数、字符常量*、无符号整数、无符号整数、整数、无符号整数、无符号字符、整数、无效常量*) “uuuu_uuuglewgenbuffers”,引用自: Euchre-d6b330.o中的unsigned int Euchre::MakeObject::makeBufferObject(int,unsigned int,unsigned int,std:u 1::vector) Euchre-d6b330.o中的unsigned int Euchre::MakeObject::makeBufferObject(int,unsigned int,unsigned int,std:u 1::vector) “uuuu_uuuuglewgenvertexarrays”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::makeVertexArrayObject(int) “GlewGetAttributeLocation”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::makeAttribute(无符号整数、字符常量*、无符号整数、无符号整数、整数、无符号整数、无符号字符、整数、无效常量*) “uuu_uuuglewgetshaderiv”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::compileShader(unsigned int,std:_1::basic_string const&) “glewLinkProgram”,参考自: Euchre-d6b330.o中的Euchre::MakeObject::LoadShader(char const*,char const*) “uuuu_uuuuGlewshaderSource”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::compileShader(unsigned int,std:_1::basic_string const&) “glewUseProgram”,引用自: _干管输入干管-6799fc.o “GlewVertexAttribute指针”,引用自: Euchre-d6b330.o中的Euchre::MakeObject::makeAttribute(无符号整数、字符常量*、无符号整数、无符号整数、整数、无符号整数、无符号字符、整数、无效常量*) “_glewExperimental”,引用自: _干管输入干管-6799fc.o “_glewInit”,引用自: _干管输入干管-6799fc.o ld:找不到架构x86_64的符号 叮当声:错误:链接器命令失败,退出代码为1(使用-v查看调用)
我不明白的是,我是如何使用与Xcode相同的设置进行编译的,但在terminal中,我无法实现这一点。

如果需要更多信息,请询问,我将提供!我不想过份地回答这个问题。你实际上并没有链接到glew或SOIL库。另外,你也没有编译头文件,它们是作为源文件的一部分编译的。@JoachimPileborg。你是什么意思?你是说我应该把-L移到图书馆?那利比亚的土壤呢?我也可以从命令中删除Euchre.h吗?
-L
选项告诉链接器将指定的路径添加到用于使用
-L
选项搜索库的路径列表中。您需要添加例如
-lglew
以实际链接到库,并且应该在列出源(或对象)文件后放置它。是的,您可以从编译中删除头文件。