为此,我使用数学库Eigen.但是,当我尝试构建时,我收到链接错误.我过去没有太多使用过C语言,对这个错误所做的研究对我没有帮助.
这是编译器的输出:
1>------ Build started: Project: TX52-3DStereo-RT-CUDA,Configuration: DeBUG x64 ------1>Build started 06/12/2013 10:55:56.1>InitializeBuildStatus:1> touching "x64\DeBUG\TX52-3DStereo-RT-CUDA.unsuccessfulbuild".1>AddCudaCompilePropsDeps:1>SkipPing target "AddCudaCompilePropsDeps" because all output files are up-to-date with respect to the input files.1>CudaBuild:1> Compiling CUDA source file kernel.cu...1> 1> C:\Users\Satanikas\documents\Visual Studio 2012\Projects\TX52-3DStereo-RT-CUDA\TX52-3DStereo-RT-CUDA>"C:\Program files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2012 -ccbin "C:\Program files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64" -I"C:\Program files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include" -I"C:\Program files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include" -G --keep-dir x64\DeBUG -maxrregcount=0 --machine 64 --compile -cudart static -g -DWIN64 -D_DEBUG -D_CONSolE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o x64\DeBUG\kernel.cu.obj "C:\Users\Satanikas\documents\Visual Studio 2012\Projects\TX52-3DStereo-RT-CUDA\TX52-3DStereo-RT-CUDA\kernel.cu" 1>c:\users\satanikas\documents\visual studio 2012\common\inc\eigen\src/Core/arch/SSE/PacketMath.h(169): warning : controlling Expression is constant1> 1>c:\users\satanikas\documents\visual studio 2012\common\inc\eigen\src/Core/Block.h(102): error : "operator=" has already been declared in the current scope1> detected during instantiation of class "Eigen::Block<XprType,BlockRows,BlockCols,InnerPanel> [with XprType=VectorType,BlockRows=<Expression>,BlockCols=<Expression>,InnerPanel=false]" 1> c:\users\satanikas\documents\visual studio 2012\common\inc\eigen\src/Core/VectorBlock.h(58): here1> 1>c:\users\satanikas\documents\visual studio 2012\common\inc\eigen\src/Core/Ref.h(122): error : "operator=" has already been declared in the current scope1> detected during instantiation of class "Eigen::RefBase<Derived> [with Derived=Eigen::Ref<PlainObjectType,Options,StrIDeType>]" 1> (183): here1> 1>c:\users\satanikas\documents\visual studio 2012\common\inc\eigen\src/Core/products/Parallelizer.h(20): warning : variable "m_maxThreads" was set but never used1> 1>c:\users\satanikas\documents\visual studio 2012\common\inc\eigen\src/Geometry/RotationBase.h(76): error : function template "Eigen::operator*(const Eigen::EigenBase<OtherDerived> &,const Eigen::Quaternion<_Scalar,_Options> &)" has already been defined1> detected during:1> instantiation of class "Eigen::RotationBase<Derived,_Dim> [with Derived=Eigen::Quaternion<_Scalar,_Options>,_Dim=3]" 1> c:\users\satanikas\documents\visual studio 2012\common\inc\eigen\src/Geometry/Quaternion.h(35): here1> instantiation of class "Eigen::QuaternionBase<Derived> [with Derived=Eigen::Quaternion<_Scalar,_Options>]" 1> c:\users\satanikas\documents\visual studio 2012\common\inc\eigen\src/Geometry/Quaternion.h(236): here1> 1> 3 errors detected in the compilation of "C:/Users/SatanI~1/AppData/Local/Temp/tmpxft_000010c8_00000000-5_kernel.cpp1.ii".1>C:\Program files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 5.5.targets(592,9): error MSB3721: The command ""C:\Program files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe" -gencode=arch=compute_10,compute_10\" --use-local-env --cl-version 2012 -ccbin "C:\Program files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64" -I"C:\Program files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include" -I"C:\Program files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include" -G --keep-dir x64\DeBUG -maxrregcount=0 --machine 64 --compile -cudart static -g -DWIN64 -D_DEBUG -D_CONSolE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o x64\DeBUG\kernel.cu.obj "C:\Users\Satanikas\documents\Visual Studio 2012\Projects\TX52-3DStereo-RT-CUDA\TX52-3DStereo-RT-CUDA\kernel.cu"" exited with code 2.1>1>Build Failed.1>1>Time Elapsed 00:00:03.40========== Build: 0 succeeded,1 Failed,0 up-to-date,0 skipped ==========
错误来自3个类,这里是它们的标题:
#pragma once#include <Eigen\Geometry>class transformedobject{public: transformedobject(voID); ~transformedobject(voID); voID rotate(const Eigen::Quaternionf&); voID setRotation(const Eigen::Quaternionf&); voID translate(const Eigen::Vector3f&); voID setTranslation(const Eigen::Vector3f&); voID scale(const float&); const Eigen::Matrix4f getMatrix(voID); Eigen::transform<float,3,Eigen::Affine> transform;};#pragma once#include "transformedobject.h"class Camera{public: Camera(voID); ~Camera(voID); voID computerays(); voID setFOV(float angle); voID setResolution(int w,int h);private: transformedobject transformation; float fov; unsigned int wIDth; unsigned int height; float* raysDirections; Eigen::Vector3f raysOrigin;};#pragma once#include <forward_List>#include "transformedobject.h"class ScenegraphNode{public: ScenegraphNode(voID); ~ScenegraphNode(voID);private: transformedobject transformation; size_t sceneHash; std::forward_List<ScenegraphNode*> children; int countVertices() const;};
如您所见,所有类都有“pragma once”,而且Eigen类都由ifndef / define / endif保护.
我收集的是,这可能是由于我的代码由不同的TU编译,其中包括Eigen,因此所有“已经定义”的错误.但是我不知道如何纠正这个问题(我不能使用extern,因为我使用我的类transformedobject作为其他类的成员).
提前致谢,
解决方法 复制user3073879(提交者)评论:“问题解决了,我从包含声明摄像机的主机功能的文件中删除了所有CUDA代码.(这是一个测试功能).这意味着它确实是NVCC的一个问题”
把这个问题标记为已回答.
总结以上是内存溢出为你收集整理的c – VS2012抱怨“已经定义”的课程,尽管有一次pragma全部内容,希望文章能够帮你解决c – VS2012抱怨“已经定义”的课程,尽管有一次pragma所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)