I have c++ classes that are needed to import in python.
For that I am using SWIG. Below is the swig interface
example.i
/* File: example.i */
%module example
%{
#include "Item.h"
#include "GradedDouble.h"
#include "GradedComplex.h"
%}
%include <std_string.i>
%include <std_complex.i>
%include "Item.h"
%include "GradedDouble.h"
%include "GradedComplex.h"
%template(Int) Item<int>;
%template(Complex) Item<std::complex<double> >;
And for creating wrapper class and python module I am executing following command in windows XP environment
c:\>swig -c++ -python -nodefaultctor example.i
c:\>python setup.py build_ext --inplace
After executing second command I am getting the following error :
*C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python26\libs /LIBPATH:C:\Python26\PCbuild /EXPORT:init_example build\temp.win32-2.6\Release\example_wrap.obj "/OUT:C:\Documents and Settings\swig_example.pyd" /IMPLIB:build\temp.win32-2.6\Release\_example.lib /MANIFESTFILE:build\temp.win32-2.6\Release\_example.pyd.manifest
Creating library build\temp.win32-2.6\Release\_example.lib and object build\temp.win32-2.6\Release\_example.exp
example_wrap.obj : error LNK2019: unresolved external symbol "public: __thiscall GradedDouble::~GradedDouble(void)" (??1GradedDouble##QAE#XZ) referenced in function __wrap_delete_GradedDouble
example_wrap.obj : error LNK2019: unresolved external symbol "public: __thiscall GradedComplex::~GradedComplex(void)" (??1GradedComplex##QAE#XZ) referenced in function __wrap_delete_GradedComplex
example_wrap.obj : error LNK2019: unresolved external symbol "public: __thiscall GradedDouble::GradedDouble(int,double *)" (??0GradedDouble##QAE#HPAN#Z) referenced in function __wrap_new_GradedDouble
example_wrap.obj : error LNK2019: unresolved external symbol "public: void __thiscall GradedDouble::avg(double *)" (?avg#GradedDouble##QAEXPAN#Z) referenced in function __wrap_GradedDouble_avg
example_wrap.obj : error LNK2019: unresolved external symbol "public: __thiscall GradedComplex::GradedComplex(int,double *)" (??0GradedComplex##QAE#HPAN#Z) referenced in function __wrap_new_GradedComplex
example_wrap.obj : error LNK2019: unresolved external symbol "public: void __thiscall GradedComplex::avg(double *)" (?avg#GradedComplex##QAEXPAN#Z) referenced in function __wrap_GradedComplex_avg
example_wrap.obj : error LNK2019: unresolved external symbol "public: void __thiscall GradedComplex::push(class Item<class std::complex<double> >)" (?push#GradedComplex##QAEXV?$Item#V?$complex#N#std#####Z) referenced in function __wrap_GradedComplex_push
example_wrap.obj : error LNK2019: unresolved external symbol "public: void __thiscall GradedDouble::push(class Item<double>)" (?push#GradedDouble##QAEXV?$Item#N###Z) referenced in function __wrap_GradedDouble_push
C:\Documents and Settings\swig_example.pyd : fatal error LNK1120: 8 unresolved externals
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe"'failed with exit status 1120*
It seems there are issue in creating interface file of swig (example.i)
I need help for creating interface file. Following are the header files
GradedComplex.h
#ifndef __GRADEDCOMPLEX_H__
#define __GRADEDCOMPLEX_H__
#include <complex>
#include <set>
#include <vector>
#include "Item.h"
class GradedComplex
{
public:
typedef std::complex<double> dcomplex;
typedef Item<dcomplex> item_type;
typedef ItemComparator<dcomplex> comparator;
typedef std::set<item_type, comparator> grade_type;
private:
int n_;
std::vector<grade_type *> grade_;
std::vector<double> thre_;
public:
GradedComplex(int n, double *thre);
~GradedComplex();
void push(item_type item);
void avg(double *buf);
};
#endif
Graded Double.h
#ifndef __GRADEDDOUBLE_H__
#define __GRADEDDOUBLE_H__
#include <set>
#include <vector>
#include "Item.h"
class GradedDouble
{
public:
typedef Item<double> item_type;
typedef ItemComparator<double> comparator;
typedef std::set<item_type, comparator> grade_type;
private:
int n_;
std::vector<grade_type *> grade_;
std::vector<double> thre_;
public:
GradedDouble(int n, double *thre);
~GradedDouble();
void push(item_type item);
void avg(double *buf);
};
#endif
Please help me for creating correct SWIG interface file.
It looks like the link operation is missing the definitions for your GradedDouble and GradedComplex classes.
You have to provide these definitions to the linker, either in the form of object files, or in the form of a library.
I don't know enough about SWIG on Windows (only use it on Linux) to be able to help further on how to solve this.
Related
recently I'm working on a UE5 project that uses filesystem to read and render a .obj file directly from a given path, but my code generates 58 LNK2019 errors around the read file process after compiling it. I have tried many possible solutions like #include everything that I may need. However, the LNK2019 still exists.
Then I comment everything out of my file and I found that even if my .cpp and .h are empty but have #include <filesystem> it causes 5 LNK2019 errors. When I delete this file and create another one, then include it, it happens again. I didn't found what the compiler version of UE5 working set is, but it's said to be C++17
Basically this is my .cpp
#include "OBJMeshComponent.h"
//yes literally just one line.
and this is my .h
#pragma once
#include "CoreMinimal.h"
#include "ProceduralMeshComponent.h"
#include <fstream>
#include <iostream>
#include <filesystem> // this causes 5 LNK2019
#include "OBJMeshComponent.generated.h"
UCLASS()
class PROJECT_API UOBJMeshComponent : public UProceduralMeshComponent
{
GENERATED_BODY()
//as you can see it is empty
};
for the build output file:
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2019: 无法解析的外部符号 "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc#std##YAXXZ),函数 "protected: void __cdecl std::time_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Getvals<wchar_t>(wchar_t,class std::_Locinfo const &)" (??$_Getvals#_W#?$time_get#DV?$istreambuf_iterator#DU?$char_traits#D#std###std###std##IEAAX_WAEBV_Locinfo#1##Z) 中引用了该符号
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc#std##YAXXZ)
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2001: 无法解析的外部符号 _Mbrtowc
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 _Mbrtowc
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: struct _Cvtvec __cdecl std::_Locinfo::_Getcvt(void)const " (__imp_?_Getcvt#_Locinfo#std##QEBA?AU_Cvtvec##XZ),函数 "protected: void __cdecl std::time_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Getvals<wchar_t>(wchar_t,class std::_Locinfo const &)" (??$_Getvals#_W#?$time_get#DV?$istreambuf_iterator#DU?$char_traits#D#std###std###std##IEAAX_WAEBV_Locinfo#1##Z) 中引用了该符号
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: struct _Cvtvec __cdecl std::_Locinfo::_Getcvt(void)const " (__imp_?_Getcvt#_Locinfo#std##QEBA?AU_Cvtvec##XZ)
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: unsigned short const * __cdecl std::_Locinfo::_W_Getdays(void)const " (__imp_?_W_Getdays#_Locinfo#std##QEBAPEBGXZ),函数 "protected: void __cdecl std::time_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Getvals<wchar_t>(wchar_t,class std::_Locinfo const &)" (??$_Getvals#_W#?$time_get#DV?$istreambuf_iterator#DU?$char_traits#D#std###std###std##IEAAX_WAEBV_Locinfo#1##Z) 中引用了该符号
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: unsigned short const * __cdecl std::_Locinfo::_W_Getdays(void)const " (__imp_?_W_Getdays#_Locinfo#std##QEBAPEBGXZ)
OBJProceduralMeshComponent.gen.cpp.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: unsigned short const * __cdecl std::_Locinfo::_W_Getmonths(void)const " (__imp_?_W_Getmonths#_Locinfo#std##QEBAPEBGXZ),函数 "protected: void __cdecl std::time_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Getvals<wchar_t>(wchar_t,class std::_Locinfo const &)" (??$_Getvals#_W#?$time_get#DV?$istreambuf_iterator#DU?$char_traits#D#std###std###std##IEAAX_WAEBV_Locinfo#1##Z) 中引用了该符号
OBJProceduralMeshComponent.cpp.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: unsigned short const * __cdecl std::_Locinfo::_W_Getmonths(void)const " (__imp_?_W_Getmonths#_Locinfo#std##QEBAPEBGXZ)
C:\Users\liuyi\Documents\Unreal Projects\Assignment2\Binaries\Win64\UnrealEditor-Assignment2.patch_0.exe : fatal error LNK1120: 5 个无法解析的外部命令
I'm trying to create a project using the QGIS class "QApplication" but it seems to fail due to an error I can´t understand.
I'm using this build version of QGIS made for QT5.7, VS2015, W10 x64 and my main.cpp just containts the following lines:
#define CORE_EXPORT __declspec(dllexport)
#include "QGisTest.h"
#include <QtWidgets/QApplication>
#include <qgsapplication.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGisTest w;
w.show();
return a.exec();
}
And when I try to build it, these errors show up:
1>------ Build started: Project: QGisTest, Configuration: Release x64 ------
1> moc_qgsapplication.cpp
1> Creating library C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.lib and object C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.exp
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QMap<class QString,class QString> QgsApplication::mSystemEnvVars21800" (?mSystemEnvVars21800#QgsApplication##0V?$QMap#VQString##V1###A) referenced in function "public: static class QMap<class QString,class QString> __cdecl QgsApplication::systemEnvVars(void)" (?systemEnvVars#QgsApplication##SA?AV?$QMap#VQString##V1###XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QMap<class QString,class QString> QgsApplication::mSystemEnvVars21800" (?mSystemEnvVars21800#QgsApplication##0V?$QMap#VQString##V1###A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static bool QgsApplication::mRunningFromBuildDir21800" (?mRunningFromBuildDir21800#QgsApplication##0_NA) referenced in function "public: static bool __cdecl QgsApplication::isRunningFromBuildDir(void)" (?isRunningFromBuildDir#QgsApplication##SA_NXZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static bool QgsApplication::mRunningFromBuildDir21800" (?mRunningFromBuildDir21800#QgsApplication##0_NA)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildSourcePath21800" (?mBuildSourcePath21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::buildSourcePath(void)" (?buildSourcePath#QgsApplication##SA?AVQString##XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mBuildSourcePath21800" (?mBuildSourcePath21800#QgsApplication##0VQString##A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mCfgIntDir21800" (?mCfgIntDir21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::cfgIntDir(void)" (?cfgIntDir#QgsApplication##SA?AVQString##XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mCfgIntDir21800" (?mCfgIntDir21800#QgsApplication##0VQString##A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildOutputPath21800" (?mBuildOutputPath21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::buildOutputPath(void)" (?buildOutputPath#QgsApplication##SA?AVQString##XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QString QgsApplication::mBuildOutputPath21800" (?mBuildOutputPath21800#QgsApplication##0VQString##A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QStringList QgsApplication::mGdalSkipList21800" (?mGdalSkipList21800#QgsApplication##0VQStringList##A) referenced in function "public: static class QStringList __cdecl QgsApplication::skippedGdalDrivers(void)" (?skippedGdalDrivers#QgsApplication##SA?AVQStringList##XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class QStringList QgsApplication::mGdalSkipList21800" (?mGdalSkipList21800#QgsApplication##0VQStringList##A)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static int QgsApplication::mMaxThreads21800" (?mMaxThreads21800#QgsApplication##0HA) referenced in function "public: static int __cdecl QgsApplication::maxThreads(void)" (?maxThreads#QgsApplication##SAHXZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static int QgsApplication::mMaxThreads21800" (?mMaxThreads21800#QgsApplication##0HA)
1>C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\\QGisTest.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I also added to the project this "moc_qgsapplication.cpp" and wrote the line:
#define CORE_EXPORT __declspec(dllexport)
to avoid other compilation problems and linked to the project the QGIS and QT 5.7 libs.
Any idea how to fix it?
EDIT:
I have changed the two lines of main.cpp as suggested and now contains the following code:
#define CORE_EXPORT __declspec(dllimport)
#include "QGisTest.h"
#include <QApplication>
#include <qgsapplication.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGisTest w;
w.show();
return a.exec();
}
but when I try to build it, these erros still show up:
1>------ Build started: Project: QGisTest, Configuration: Release x64 ------
1> moc_qgsapplication.cpp
1> main.cpp
1> Generating Code...
1> Creating library C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.lib and object C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\QGisTest.exp
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QMap<class QString,class QString> QgsApplication::mSystemEnvVars21800" (?mSystemEnvVars21800#QgsApplication##0V?$QMap#VQString##V1###A) referenced in function "public: static class QMap<class QString,class QString> __cdecl QgsApplication::systemEnvVars(void)" (?systemEnvVars#QgsApplication##SA?AV?$QMap#VQString##V1###XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static bool QgsApplication::mRunningFromBuildDir21800" (?mRunningFromBuildDir21800#QgsApplication##0_NA) referenced in function "public: static bool __cdecl QgsApplication::isRunningFromBuildDir(void)" (?isRunningFromBuildDir#QgsApplication##SA_NXZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildSourcePath21800" (?mBuildSourcePath21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::buildSourcePath(void)" (?buildSourcePath#QgsApplication##SA?AVQString##XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mCfgIntDir21800" (?mCfgIntDir21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::cfgIntDir(void)" (?cfgIntDir#QgsApplication##SA?AVQString##XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QString QgsApplication::mBuildOutputPath21800" (?mBuildOutputPath21800#QgsApplication##0VQString##A) referenced in function "public: static class QString __cdecl QgsApplication::buildOutputPath(void)" (?buildOutputPath#QgsApplication##SA?AVQString##XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static class QStringList QgsApplication::mGdalSkipList21800" (?mGdalSkipList21800#QgsApplication##0VQStringList##A) referenced in function "public: static class QStringList __cdecl QgsApplication::skippedGdalDrivers(void)" (?skippedGdalDrivers#QgsApplication##SA?AVQStringList##XZ)
1>moc_qgsapplication.obj : error LNK2019: unresolved external symbol "private: static int QgsApplication::mMaxThreads21800" (?mMaxThreads21800#QgsApplication##0HA) referenced in function "public: static int __cdecl QgsApplication::maxThreads(void)" (?maxThreads#QgsApplication##SAHXZ)
1>C:\Users\GRODRIGUEZ\Documents\Visual Studio 2015\Projects\QGisTest\x64\Release\\QGisTest.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I get the error below when i call new TerrainClass() from the main, tried for hours to fix it, help please.
error LNK2019: unresolved external symbol "public: __thiscall TerrainClass::TerrainClass(void)" (??0TerrainClass##QAE#XZ) referenced in function "void __cdecl init(void)" (?init##YAXXZ)
GLDrawObject.h
#pragma once
class GLDrawObject
{
};
Terrain.cpp
#pragma once
TerrainClass::TerrainClass() : GLDrawObject()
{
}
Terrain.h
#pragma once
#include "GLDrawObject.h"
class TerrainClass : public GLDrawObject
{
public:
TerrainClass();
};
Firstly, your Terrain.cpp should be as follows:
#include "Terrain.h"
TerrainClass::TerrainClass() : GLDrawObject()
{
}
Secondly, you are getting a linker error, not a compiler error; once compiled, you need to link Terrain.o with the rest of your object files.
I am trying to implement a PointArray class derived from a template. Here is what my hpp file for PointArray looks like:
#ifndef POINTARRAY_H
#define POINTARRAY_H
#include <iostream>
#include <sstream>
#include <stdio.h>
#include "Array.hpp"
using namespace Abhishek::CAD;
using namespace Abhishek::CONTAINERS;
namespace Abhishek
{
namespace CONTAINERS
{
class PointArray : public Array<Point>
{
public:
PointArray();//Default constrcutor.
PointArray(int size);//Constructor with size argument.
PointArray(const PointArray& arr);//Copy constructor.
~PointArray();//Destructor.
double Length() const;//Length function.
};
}
}
#endif
My cpp looks like this :
#include <iostream>
#include <sstream>
#include <stdio.h>
#include "PointArray.hpp"
using namespace Abhishek::CAD;
using namespace Abhishek::CONTAINERS;
namespace Abhishek
{
namespace CONTAINERS
{
//Default constructor.
PointArray::PointArray(): Array<Point>()
{
cout<<"Point arr default cons"<<endl;
}
//Constructor with size argument.
PointArray::PointArray(int size) : Array<Point>(size)
{
}
//Copy constructor.
PointArray::PointArray(const PointArray& arr) : Array<Point>(arr)
{
}
//destrcutor.
PointArray::~PointArray()
{
}
}
}
I get the LNK error :
error LNK2019: unresolved external symbol "public: __thiscall Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point>::Array<class Abhishek::CAD::Point>(void)" (??0?$Array#VPoint#CAD#Abhishek###CONTAINERS#Abhishek##QAE#XZ) referenced in function "public: __thiscall Abhishek::CONTAINERS::PointArray::PointArray(void)" (??0PointArray#CONTAINERS#Abhishek##QAE#XZ)
1>PointArray.obj : error LNK2019: unresolved external symbol "public: __thiscall Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point>::Array<class Abhishek::CAD::Point>(int)" (??0?$Array#VPoint#CAD#Abhishek###CONTAINERS#Abhishek##QAE#H#Z) referenced in function "public: __thiscall Abhishek::CONTAINERS::PointArray::PointArray(int)" (??0PointArray#CONTAINERS#Abhishek##QAE#H#Z)
1>PointArray.obj : error LNK2019: unresolved external symbol "public: __thiscall Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point>::Array<class Abhishek::CAD::Point>(class Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point> const &)" (??0?$Array#VPoint#CAD#Abhishek###CONTAINERS#Abhishek##QAE#ABV012##Z) referenced in function "public: __thiscall Abhishek::CONTAINERS::PointArray::PointArray(class Abhishek::CONTAINERS::PointArray const &)" (??0PointArray#CONTAINERS#Abhishek##QAE#ABV012##Z)
1>PointArray.obj : error LNK2019: unresolved external symbol "public: __thiscall Abhishek::CONTAINERS::Array<class Abhishek::CAD::Point>::~Array<class Abhishek::CAD::Point>(void)" (??1?$Array#VPoint#CAD#Abhishek###CONTAINERS#Abhishek##QAE#XZ) referenced in function __unwindfunclet$??0PointArray#CONTAINERS#Abhishek##QAE#XZ$0
1>C:\Users\Rambo\Documents\Level 6\Section 4.2b\Exercise 3\Debug\Exercise 3.exe : fatal error LNK1120: 4 unresolved externals
I dont understand why this could be happening. I included all the relevant header files and CPP files. If anyone can help I will really appreciate it.
You forgot to post the most relevant header: the one that declares the class template that causes the error. Almost certainly, that header declares the default constructor of the Array template:
Array();
but doesn't define it; either there is no definition, or you have a definition in a source file.
In either case, you'll get an error since templates must be defined in any translation unit that uses them. This means that you'll need to define the constructor (and any other member functions) in the header, to include them wherever they are used.
If that's not the problem, then please post the header so we can investigate further.
Code
#include <OOLua/oolua.h>
class foo
{
public:
int bar();
};
OOLUA_CLASS_NO_BASES(foo)//class has no bases
OOLUA_NO_TYPEDEFS
OOLUA_MEM_FUNC_0(int,bar)
OOLUA_CLASS_END
void test()
{
OOLUA::Script s;
s.register_class<foo>();
}
Compiler output
1>main.obj : error LNK2001: unresolved external symbol "public: static struct OOLUA::Proxy_class<class foo>::Reg_type_const * OOLUA::Proxy_class<class foo>::class_methods_const" (?class_methods_const#?$Proxy_class#Vfoo###OOLUA##2PAUReg_type_const#12#A)
1>main.obj : error LNK2001: unresolved external symbol "public: static struct OOLUA::Proxy_class<class foo>::Reg_type * OOLUA::Proxy_class<class foo>::class_methods" (?class_methods#?$Proxy_class#Vfoo###OOLUA##2PAUReg_type#12#A)
1>main.obj : error LNK2001: unresolved external symbol "public: static char const * const OOLUA::Proxy_class<class foo>::class_name" (?class_name#?$Proxy_class#Vfoo###OOLUA##2QBDB)
1>main.obj : error LNK2001: unresolved external symbol "public: static char const * const OOLUA::Proxy_class<class foo>::class_name_const" (?class_name_const#?$Proxy_class#Vfoo###OOLUA##2QBDB)
1>main.obj : error LNK2001: unresolved external symbol "public: static int const OOLUA::Proxy_class<class foo>::name_size" (?name_size#?$Proxy_class#Vfoo###OOLUA##2HB)
Using
Visual Studio 2008
OOLua 1.2.1
(OOLua .lib has been built and linked to)
(OOLua solution via premake 3 with test.unit and profile projects removed)
(OOLua obtained via SVN -> trunk | Jan 3rd)
Links
http://code.google.com/p/oolua/
OOLua compile errors
Question
How can it be fixed?
Solution
class foo
{
public:
int bar()
{
return 0;
}
};
OOLUA_CLASS_NO_BASES(foo)//class has no bases
OOLUA_NO_TYPEDEFS
OOLUA_MEM_FUNC_0(int,bar)
OOLUA_CLASS_END
EXPORT_OOLUA_FUNCTIONS_1_NON_CONST(foo /*name of class*/
,bar)/*function being exposed*/
EXPORT_OOLUA_FUNCTIONS_0_CONST(foo)
void test()
{
OOLUA::Script s;
s.register_class<foo>();
}
http://code.google.com/p/oolua/wiki/CheatSheet#Has_a_member_function_which_takes_no_parameters
Then in a source file expose the class
telling the framework that the
instance has a function of interest
yet no constant member functions, also
providing the name it will be
identified by in Lua code(foo).
EXPORT_OOLUA_FUNCTIONS_1_NON_CONST(foo /*name of class*/
,bar)/*function being exposed*/
EXPORT_OOLUA_FUNCTIONS_0_CONST(foo)