Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mac上架构x86_64的未定义符号 我用GCC 7.8用cLIN进行C++编码。我们有这段代码,它用于从*.OBJ文件“渲染”图像 #ifndef __GEOMETRY_H__ #define __GEOMETRY_H__ #include <cmath> template <class t> struct Vec2 { t x, y; Vec2<t>() : x(t()), y(t()) {} Vec2<t>(t _x, t _y) : x(_x), y(_y) {} Vec2<t>(const Vec2<t> &v) : x(t()), y(t()) { *this = v; } Vec2<t> & operator =(const Vec2<t> &v) { if (this != &v) { x = v.x; y = v.y; } return *this; } Vec2<t> operator +(const Vec2<t> &V) const { return Vec2<t>(x+V.x, y+V.y); } Vec2<t> operator -(const Vec2<t> &V) const { return Vec2<t>(x-V.x, y-V.y); } Vec2<t> operator *(float f) const { return Vec2<t>(x*f, y*f); } t& operator[](const int i) { if (x<=0) return x; else return y; } template <class > friend std::ostream& operator<<(std::ostream& s, Vec2<t>& v); }; template <class t> struct Vec3 { t x, y, z; Vec3<t>() : x(t()), y(t()), z(t()) { } Vec3<t>(t _x, t _y, t _z) : x(_x), y(_y), z(_z) {} template <class u> Vec3<t>(const Vec3<u> &v); Vec3<t>(const Vec3<t> &v) : x(t()), y(t()), z(t()) { *this = v; } Vec3<t> & operator =(const Vec3<t> &v) { if (this != &v) { x = v.x; y = v.y; z = v.z; } return *this; } Vec3<t> operator ^(const Vec3<t> &v) const { return Vec3<t>(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x); } Vec3<t> operator +(const Vec3<t> &v) const { return Vec3<t>(x+v.x, y+v.y, z+v.z); } Vec3<t> operator -(const Vec3<t> &v) const { return Vec3<t>(x-v.x, y-v.y, z-v.z); } Vec3<t> operator *(float f) const { return Vec3<t>(x*f, y*f, z*f); } t operator *(const Vec3<t> &v) const { return x*v.x + y*v.y + z*v.z; } float norm () const { return std::sqrt(x*x+y*y+z*z); } Vec3<t> & normalize(t l=1) { *this = (*this)*(l/norm()); return *this; } t& operator[](const int i) { if (i<=0) return x; else if (i==1) return y; else return z; } template <class > friend std::ostream& operator<<(std::ostream& s, Vec3<t>& v); }; typedef Vec2<float> Vec2f; typedef Vec2<int> Vec2i; typedef Vec3<float> Vec3f; typedef Vec3<int> Vec3i; template <> template <> Vec3<int>::Vec3(const Vec3<float> &v); template <> template <> Vec3<float>::Vec3(const Vec3<int> &v); template <class t> std::ostream& operator<<(std::ostream& s, Vec2<t>& v) { s << "(" << v.x << ", " << v.y << ")\n"; return s; } template <class t> std::ostream& operator<<(std::ostream& s, Vec3<t>& v) { s << "(" << v.x << ", " << v.y << ", " << v.z << ")\n"; return s; } #endif //__GEOMETRY_H__ \ifndef\uu几何体\uh__ #定义几何图形__ #包括 模板结构Vec2{ tx,y; Vec2():x(t()),y(t()){} Vec2(t_x,t_y):x(x),y(y){ Vec2(constvec2&v):x(t()),y(t()){*this=v;} Vec2&运算符=(常量Vec2&v){ 如果(此!=&v){ x=v.x; y=v.y; } 归还*这个; } Vec2运算符+(const Vec2&V)const{return Vec2(x+V.x,y+V.y);} Vec2运算符-(const Vec2&V)const{return Vec2(x-V.x,y-V.y);} Vec2运算符*(float f)常量{return Vec2(x*f,y*f);} t&operator[](const int i){if(x_C++_Macos_C++11_Gcc - Fatal编程技术网

Mac上架构x86_64的未定义符号 我用GCC 7.8用cLIN进行C++编码。我们有这段代码,它用于从*.OBJ文件“渲染”图像 #ifndef __GEOMETRY_H__ #define __GEOMETRY_H__ #include <cmath> template <class t> struct Vec2 { t x, y; Vec2<t>() : x(t()), y(t()) {} Vec2<t>(t _x, t _y) : x(_x), y(_y) {} Vec2<t>(const Vec2<t> &v) : x(t()), y(t()) { *this = v; } Vec2<t> & operator =(const Vec2<t> &v) { if (this != &v) { x = v.x; y = v.y; } return *this; } Vec2<t> operator +(const Vec2<t> &V) const { return Vec2<t>(x+V.x, y+V.y); } Vec2<t> operator -(const Vec2<t> &V) const { return Vec2<t>(x-V.x, y-V.y); } Vec2<t> operator *(float f) const { return Vec2<t>(x*f, y*f); } t& operator[](const int i) { if (x<=0) return x; else return y; } template <class > friend std::ostream& operator<<(std::ostream& s, Vec2<t>& v); }; template <class t> struct Vec3 { t x, y, z; Vec3<t>() : x(t()), y(t()), z(t()) { } Vec3<t>(t _x, t _y, t _z) : x(_x), y(_y), z(_z) {} template <class u> Vec3<t>(const Vec3<u> &v); Vec3<t>(const Vec3<t> &v) : x(t()), y(t()), z(t()) { *this = v; } Vec3<t> & operator =(const Vec3<t> &v) { if (this != &v) { x = v.x; y = v.y; z = v.z; } return *this; } Vec3<t> operator ^(const Vec3<t> &v) const { return Vec3<t>(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x); } Vec3<t> operator +(const Vec3<t> &v) const { return Vec3<t>(x+v.x, y+v.y, z+v.z); } Vec3<t> operator -(const Vec3<t> &v) const { return Vec3<t>(x-v.x, y-v.y, z-v.z); } Vec3<t> operator *(float f) const { return Vec3<t>(x*f, y*f, z*f); } t operator *(const Vec3<t> &v) const { return x*v.x + y*v.y + z*v.z; } float norm () const { return std::sqrt(x*x+y*y+z*z); } Vec3<t> & normalize(t l=1) { *this = (*this)*(l/norm()); return *this; } t& operator[](const int i) { if (i<=0) return x; else if (i==1) return y; else return z; } template <class > friend std::ostream& operator<<(std::ostream& s, Vec3<t>& v); }; typedef Vec2<float> Vec2f; typedef Vec2<int> Vec2i; typedef Vec3<float> Vec3f; typedef Vec3<int> Vec3i; template <> template <> Vec3<int>::Vec3(const Vec3<float> &v); template <> template <> Vec3<float>::Vec3(const Vec3<int> &v); template <class t> std::ostream& operator<<(std::ostream& s, Vec2<t>& v) { s << "(" << v.x << ", " << v.y << ")\n"; return s; } template <class t> std::ostream& operator<<(std::ostream& s, Vec3<t>& v) { s << "(" << v.x << ", " << v.y << ", " << v.z << ")\n"; return s; } #endif //__GEOMETRY_H__ \ifndef\uu几何体\uh__ #定义几何图形__ #包括 模板结构Vec2{ tx,y; Vec2():x(t()),y(t()){} Vec2(t_x,t_y):x(x),y(y){ Vec2(constvec2&v):x(t()),y(t()){*this=v;} Vec2&运算符=(常量Vec2&v){ 如果(此!=&v){ x=v.x; y=v.y; } 归还*这个; } Vec2运算符+(const Vec2&V)const{return Vec2(x+V.x,y+V.y);} Vec2运算符-(const Vec2&V)const{return Vec2(x-V.x,y-V.y);} Vec2运算符*(float f)常量{return Vec2(x*f,y*f);} t&operator[](const int i){if(x

Mac上架构x86_64的未定义符号 我用GCC 7.8用cLIN进行C++编码。我们有这段代码,它用于从*.OBJ文件“渲染”图像 #ifndef __GEOMETRY_H__ #define __GEOMETRY_H__ #include <cmath> template <class t> struct Vec2 { t x, y; Vec2<t>() : x(t()), y(t()) {} Vec2<t>(t _x, t _y) : x(_x), y(_y) {} Vec2<t>(const Vec2<t> &v) : x(t()), y(t()) { *this = v; } Vec2<t> & operator =(const Vec2<t> &v) { if (this != &v) { x = v.x; y = v.y; } return *this; } Vec2<t> operator +(const Vec2<t> &V) const { return Vec2<t>(x+V.x, y+V.y); } Vec2<t> operator -(const Vec2<t> &V) const { return Vec2<t>(x-V.x, y-V.y); } Vec2<t> operator *(float f) const { return Vec2<t>(x*f, y*f); } t& operator[](const int i) { if (x<=0) return x; else return y; } template <class > friend std::ostream& operator<<(std::ostream& s, Vec2<t>& v); }; template <class t> struct Vec3 { t x, y, z; Vec3<t>() : x(t()), y(t()), z(t()) { } Vec3<t>(t _x, t _y, t _z) : x(_x), y(_y), z(_z) {} template <class u> Vec3<t>(const Vec3<u> &v); Vec3<t>(const Vec3<t> &v) : x(t()), y(t()), z(t()) { *this = v; } Vec3<t> & operator =(const Vec3<t> &v) { if (this != &v) { x = v.x; y = v.y; z = v.z; } return *this; } Vec3<t> operator ^(const Vec3<t> &v) const { return Vec3<t>(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x); } Vec3<t> operator +(const Vec3<t> &v) const { return Vec3<t>(x+v.x, y+v.y, z+v.z); } Vec3<t> operator -(const Vec3<t> &v) const { return Vec3<t>(x-v.x, y-v.y, z-v.z); } Vec3<t> operator *(float f) const { return Vec3<t>(x*f, y*f, z*f); } t operator *(const Vec3<t> &v) const { return x*v.x + y*v.y + z*v.z; } float norm () const { return std::sqrt(x*x+y*y+z*z); } Vec3<t> & normalize(t l=1) { *this = (*this)*(l/norm()); return *this; } t& operator[](const int i) { if (i<=0) return x; else if (i==1) return y; else return z; } template <class > friend std::ostream& operator<<(std::ostream& s, Vec3<t>& v); }; typedef Vec2<float> Vec2f; typedef Vec2<int> Vec2i; typedef Vec3<float> Vec3f; typedef Vec3<int> Vec3i; template <> template <> Vec3<int>::Vec3(const Vec3<float> &v); template <> template <> Vec3<float>::Vec3(const Vec3<int> &v); template <class t> std::ostream& operator<<(std::ostream& s, Vec2<t>& v) { s << "(" << v.x << ", " << v.y << ")\n"; return s; } template <class t> std::ostream& operator<<(std::ostream& s, Vec3<t>& v) { s << "(" << v.x << ", " << v.y << ", " << v.z << ")\n"; return s; } #endif //__GEOMETRY_H__ \ifndef\uu几何体\uh__ #定义几何图形__ #包括 模板结构Vec2{ tx,y; Vec2():x(t()),y(t()){} Vec2(t_x,t_y):x(x),y(y){ Vec2(constvec2&v):x(t()),y(t()){*this=v;} Vec2&运算符=(常量Vec2&v){ 如果(此!=&v){ x=v.x; y=v.y; } 归还*这个; } Vec2运算符+(const Vec2&V)const{return Vec2(x+V.x,y+V.y);} Vec2运算符-(const Vec2&V)const{return Vec2(x-V.x,y-V.y);} Vec2运算符*(float f)常量{return Vec2(x*f,y*f);} t&operator[](const int i){if(x,c++,macos,c++11,gcc,C++,Macos,C++11,Gcc,为解决此问题,需要在CMake文件中添加cpp/h文件上的链接。例如,在这种情况下: project(Lesson_3_Deleting_hidden_surfaces) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(SOURCE_FILES src/IntroCG/Lesson_3_Deleting_hidden_surfaces/main.cpp) add_executable(Lesson_3_Deleting_hidde

为解决此问题,需要在CMake文件中添加cpp/h文件上的链接。例如,在这种情况下:

project(Lesson_3_Deleting_hidden_surfaces)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES src/IntroCG/Lesson_3_Deleting_hidden_surfaces/main.cpp)
add_executable(Lesson_3_Deleting_hidden_surfaces ${SOURCE_FILES}
               src/IntroCG/tgaimage.cpp src/IntroCG/tgaimage.h
               src/IntroCG/model.cpp src/IntroCG/model.h
               src/IntroCG/painter.cpp src/IntroCG/painter.h)
变成

project(Lesson_3_Deleting_hidden_surfaces)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES src/IntroCG/Lesson_3_Deleting_hidden_surfaces/main.cpp)
add_executable(Lesson_3_Deleting_hidden_surfaces ${SOURCE_FILES}
               src/IntroCG/geometry.cpp src/IntroCG/geometry.h
               src/IntroCG/tgaimage.cpp src/IntroCG/tgaimage.h
               src/IntroCG/model.cpp src/IntroCG/model.h
               src/IntroCG/painter.cpp src/IntroCG/painter.h)

为解决此问题,必须将cpp/h文件上的链接添加到CMake文件中。例如,在这种情况下:

project(Lesson_3_Deleting_hidden_surfaces)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES src/IntroCG/Lesson_3_Deleting_hidden_surfaces/main.cpp)
add_executable(Lesson_3_Deleting_hidden_surfaces ${SOURCE_FILES}
               src/IntroCG/tgaimage.cpp src/IntroCG/tgaimage.h
               src/IntroCG/model.cpp src/IntroCG/model.h
               src/IntroCG/painter.cpp src/IntroCG/painter.h)
变成

project(Lesson_3_Deleting_hidden_surfaces)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES src/IntroCG/Lesson_3_Deleting_hidden_surfaces/main.cpp)
add_executable(Lesson_3_Deleting_hidden_surfaces ${SOURCE_FILES}
               src/IntroCG/geometry.cpp src/IntroCG/geometry.h
               src/IntroCG/tgaimage.cpp src/IntroCG/tgaimage.h
               src/IntroCG/model.cpp src/IntroCG/model.h
               src/IntroCG/painter.cpp src/IntroCG/painter.h)

您正在尝试使用一些我不认识的库,因为您没有显示任何
包含
文件名或任何有助于识别它的内容。而且您的CMAkefile中似乎有一些错误,您也没有显示。嗯……您能显示您正在使用的链接器设置并提供您希望使用的库的详细信息吗?@MarkSetchell是的,谢谢你的提示。我已经在我的CMake文件中添加了指向“geometry.h”的链接。但是现在,我用Vec3构造函数记录了一条信息:“Vec3”的越界构造函数不能有模板参数”您正在尝试使用一些我不认识的库,因为您没有显示任何
包含
文件名或任何有助于识别它的内容。而且您的CMAkefile中似乎有一些错误,您也没有显示。嗯……您能显示您正在使用的链接器设置并提供您希望使用的库的详细信息吗?@MarkSetchell是的,谢谢你的提示。我已经在我的CMake文件中添加了指向“geometry.h”的链接。但是现在,我用Vec3构造函数记录了一条信息:“Vec3”的越界构造函数不能有模板参数”