void fftw_execute_dft_c2r( const fftw_plan p, fftw_complex *in, double *out); This function is one of the new-array execute functions in FFTW 3.3.7. When using this function, be careful that the input array changes. It is a side-effect of the c2r algorithms that they are hard to implement efficiently without overwriting the input.
길이가 1인 두 개의 벡터 A와 B가 주어졌을 때, 두 벡터 사이의 각도를 구하는 함수 float Angle1( const Vector& A, const Vector& B ) { return acosf( DotProduct(A,B) ); } : A와 B가 거의 평행하게 될 때 DotProduct(A,B)의 값이 -1 보다 작거나 +1 보다 큰 경우가 생기며, 이 때 문제가 발생할 수 있다. #define Clamp(x,min,max)
[ hash table (or hash map) ] – associated array: (key, value) 형식의 data를 저장하는 data structure – hash function을 사용하여 입력 key 값으로부터 hash value를 얻은 다음 이를 index로 사용하여 associated array의 형태로 저장하는 자료구조 – hash table의 각 원소: bucket 또는 slot [ hash function ] – 임의의 길이를 갖는 data를 고정된 길이의
컴파일시 error: identifier “atomicAdd” is undefined와 같은 에러가 발생한다면 다음과 같이 GPU architecture 옵션을 주면 된다. Windows Visual Studio: 속성 -> CUDA Runtime API -> GPU 에서 GPU Architecture (1)에서 sm_20으로 설정 Linux: nvcc에서 -arch sm_20 옵션을 준다.
gtkgl로 작성한 프로그램 실행시 /usr/autodesk/maya2008-x64/lib/libgcc_s.so.1: version `GCC_4.2.0′ not found (required by /usr/lib64/libstdc++.so.6)와 같은 에러가 발생하였는데, root계정으로 실행할 때에는 정상적으로 실행되는 것으로 보아 특정 파일의 permission 문제인 것으로 생각을 했었지만, LD_LIBRARY_PATH에 /usr/autodesk/maya2008-x64/lib 경로가 잡혀있기 때문에 발생한 문제였다. root계정의 .bashrc에는 저 경로가 LD_LIBRARY_PATH에 설정되어 있지 않았으므로 정상 실행된 것이었다. 파일 실행시마다 매번 root로 계정을 바꿔서 할 수는
GTK+는 LGPL(Lesser General Public License) 약관을 따른다. 즉, 간단하게 말해 GTK+ 라이브러리를 이용하여 사용 코드를 작성해도 된다는 뜻이다. 이와 비교되는 Qt는 GPL 라이센스를 따르기 때문에, 이를 이용하여 상용 프로그램을 개발할 수 없다. GTK+와 QT 모두 OpenGL과의 연동이 가능하며, 각각 GtkGLExt와 QGL을 제공하고 있다. 이 외에도 리눅스 상에서 GUI를 작성할 수 있게끔 도와주는 라이브러리로는 대표적으로 FLTK
Linux에서 Maya plugin을 complile하면 다음과 같은 error가 발생할 때가 있다. /usr/autodesk/maya2008-x64/include/maya/M3dView.h:94:27: error: X11/Intrinsic.h: No such file or directory /usr/autodesk/maya2008-x64/include/maya/M3dView.h:95: error: ‘Widget’ does not name a type /usr/autodesk/maya2008-x64/include/maya/M3dView.h:326: error: ‘MWindow’ does not name a type make: *** [/home/wano/work/maya/FXSilhouette/obj/FXSilhouette.o] Error 1 원인은 libXt package가 설치되어 있지 않은 것이다. Add/Remove Software에 가서 libXt-devel을 검색하여 설치해주면 정상적으로 컴파일이 된다.
cross platform GUI를 만들 수 있는 방법을 찾던 중 가장 눈에 띄는 wxWidgets라는 것을 발견하였다. cross platform이라는 점은 생각보다 엄청난 장점이 될 수 있다. 특히, Windows와 Linux를 동시에 사용한다면… 그리고, wxWidgets for Mac OS X까지… 그리고, 그동안 겪어왔던 MFC에 대한 울분(?)을 생각한다면… 더욱이, python, OpengGL, DirectX 등과도 연동이 가능하다면… 또한, MFC 보다 훨씬 가볍고 직관적인
boost python 사용시 (ver.1.3.7) 컴파일하면 다음과 같은 에러가 발생할 수 있다. /usr/include/bits/fcntl.h:227: error: reference to ‘ssize_t’ is ambiguous /usr/include/sys/types.h:110: error: candidates are: typedef __ssize_t ssize_t /usr/local/include/boost-1_37/boost/python/ssize_t.hpp:15: error: typedef Py_ssize_t boost::python::ssize_t /usr/include/bits/fcntl.h:227: error: reference to ‘ssize_t’ is ambiguous /usr/include/sys/types.h:110: error: candidates are: typedef __ssize_t ssize_t /usr/local/include/boost-1_37/boost/python/ssize_t.hpp:15: error: typedef Py_ssize_t boost::python::ssize_t /usr/include/bits/fcntl.h:227: error: ‘ssize_t’ does not name
“there are no arguments to ……… that depend on a template parameter” 컴파일시에 위와 같은 에러가 발생하는 이유 gcc 4.1 버전부터 표준을 더 엄격하게 지키려고 하다보니 발생하는 문제로서 일종의 버그라고 봐도 무방하다. 해결책은 다음 3가지 중 하나인데, 마지막 방법이 가장 좋다고 알려져 있다. 1. 문제가 되는 변수에 this-> 와 같이 명시적으로 변수를 사용한다. 2. 컴파일할
범하기 쉬운 실수 (CentOS 64비트 버전에서 테스트) class A { public: float a[3]; A() {} ~A() {} }; => sizeof(A) = 12 class A { public: float a[3]; A() {} virtual ~A() {} }; => sizeof(A) = 24 특히 다음과 같이
자신만의 library에 String이라는 class를 만들게 되면 Windows에서는 괜찮지만 Linux에서는 다음과 같은 error에 직면하게 된다. /usr/include/X11/Intrinsic.h:326: error: reference to ‘String’ is ambiguous. 리눅스 때문에 String이라는 좋은 이름을 두고 FString 등의 이름으로 바꿔야 하나 고민했지만, google이 문제를 해결해주었다. header 파일에 #include <String.h>을 해주기 전에 다음과 같은 처리를 해주면 된다. #define String XString #include <X11/Intrinsic.h> /* include other
#define LIFESPAN 0x000002 bool hasLifespan( int attrBitMask ) { return ( attrBitMask & LIFESPAN ); } 위와 같은 code가 있다고 했을 때, 다음과 같은 경고(warning)이 발생할 수 있다. warning C4800: ‘int’ : ‘true’ 또는 ‘false’로 bool 값을 강제하고 있습니다(성능 경고). 또는 warning C4800: ‘int’ : forcing value to bool ‘true’ or ‘false’ (performance warning) 다음과 같이
#include <Process.h> int main( int argc, char** argv ) { system( "ls" ); return 0; } 이러한 방식으로 system() 함수를 이용하여 외부 프로그램을 실행할 수 있다. 하지만, system 함수는 실행 결과의 상태를 알려주는 int 값을 리턴할 뿐 ls의 출력결과를 main 함수 내부에서 가져올 수 없다. (solution 1) 결과값을 받아오려면, 파일로 출력하여 다시 읽어들이는 방법을 이용하면
class A { public: int &x; int y; public: A(): x(y), y(0) {}; ~A() {} }; int main( int argc, char** argv ) { A a; cout << sizeof(a) << endl; return 0; } 출력결과: 12 (Linux x64에서 테스트) Reference takes it’s own space in memory.
void aaa( char* str ) { … } 일 때, aaa( “abcdefg” ); 라고 실행하면 발생하는 에러이다. 두 가지의 해결방법이 있다. 첫 번째, void aaa( const char* str ) { … } 와 같이 수정한다. 두 번째, aaa( const_cast<char*>(“abcdefg”) ); 와 같이 실행한다.
class A { public: int a, b; A(): b(0), a(0) {} }; 만약 위와 같은 code를 사용했을 때, gcc에서 다음과 같은 warning이 발생할 수 있다. warning: ‘A::a’ will be initialized after warning: when initialized here class에서 선언한 변수 순서대로 생성자에서 초기화하지 않을 때 발생하는 경고. 선언한 순서대로 초기화를 하면 warning이 발생하지 않는다.
OpenCV 2.0 사용시 다음과 같은 compile error가 발생할 수 있다. /usr/include/opencv/cxcore.hpp:266: error: expected unqualified-id before numeric constant 이것은 Complex라는 자료형이 이미 linux에서 사용되고 있기 때문이다. OpenCV의 source code 중 다음 4개 file에 있는 Complex를 cvComplex로 수정해 주면 해결된다. include/opencv/cxoperations.hpp include/opencv/cxcore.hpp src/cxcore/cxdxt.cpp src/cxcore/cxmatmul.cpp 수정한 다음 ./configure make make install 하여 설치해준다. 4개 file을 vi editor에서 수정하는
“undefined refernce to…” 이러한 error는 source code에서 어떤 외부 library를 사용하지만 해당 library가 link되어 있지 않아서 code 내용을 가져올 수 없기 때문에 발생하는 error이다. 여기서는 libz를 찾지 못해서 발생하는 compile error이므로, Makefile에 -lz 를 추가해주면 된다.
class A { public: float x; A(): x(0) {} }; std::vector av; A a; av.push_back( a ); 했을 때, can’t use default assignment operator 와 같은 error가 발생한다면, class A 에 다음 형식의 assignment operator가 정의되어 있지 않아서이다. A& operator=( const A& a ) { x = A.x; return (*this);
Visual Studio에서 다음과 같은 compile error가 발생할 때가 있다. UTL error C2872: ‘ostream’ : ambiguous symbol 이럴 때에는 C/C++ -> Preprocesser -> Preprocessor Definations에 REQUIRE_IOSTREAM를 추가해주면 된다.
다음과 같은 error가 발생할 때, C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\include\windef.h(122) : warning C4005: ‘CALLBACK’ : macro redefinition C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\GL/glut.h(34) : see previous definition of ‘CALLBACK’ #include <windows.h>를 #include <glud.h> 보다 먼저 선언해준다.
compile시 다음과 같은 error가 발생할 때, warning LNK4099: PDB ‘vc80.pdb’ was not found with라이브러리 compile시에 라이브러리 종속성 입력 사용(Link Library Dependency)를 예(Yes)로 바꿔주면 된다.