Page 1 of 1

Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 8:53 am
by jrleon
I've been trying to compile the tugOfWar from ExampleMain, but although everything was fine with cmake, when I try to build in Visual Studio 10. I get the following:

3>------ Build started: Project: Example Main, Configuration: Release x64 ------
3>Build started 6/11/2012 8:43:00 AM.
3>PrepareForBuild:
3> Creating directory "C:\Users\Juan\Documents\OpenSimWorkspace\ExampleMain\build\Release\".
3>InitializeBuildStatus:
3> Creating "TugOfWar1_CreateModel.dir\Release\Example Main.unsuccessfulbuild" because "AlwaysCreate" was specified.
3>CustomBuild:
3> Building Custom Rule C:/Users/Juan/Documents/OpenSimWorkspace/ExampleMain/CMakeLists.txt
3> CMake does not need to re-run because C:\Users\Juan\Documents\OpenSimWorkspace\ExampleMain\build\CMakeFiles\generate.stamp is up-to-date.
3>ClCompile:
3> TugOfWar1_CreateModel.cpp
3>C:/OpenSim2.4.0/sdk/include\OpenSim/Simulation/Model/ModelComponent.h(96): warning C4267: 'return' : conversion from 'size_t' to 'int', possible loss of data
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol __imp_RegisterTypes_osimTools referenced in function "public: __cdecl osimInstantiator::osimInstantiator(void)" (??0osimInstantiator@@QEAA@XZ)
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol __imp_RegisterTypes_osimAnalyses referenced in function "public: __cdecl osimInstantiator::osimInstantiator(void)" (??0osimInstantiator@@QEAA@XZ)
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol __imp_RegisterTypes_osimActuators referenced in function "public: __cdecl osimInstantiator::osimInstantiator(void)" (??0osimInstantiator@@QEAA@XZ)
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol __imp_RegisterTypes_osimSimulation referenced in function "public: __cdecl osimInstantiator::osimInstantiator(void)" (??0osimInstantiator@@QEAA@XZ)
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol __imp_RegisterTypes_osimCommon referenced in function "public: __cdecl osimInstantiator::osimInstantiator(void)" (??0osimInstantiator@@QEAA@XZ)
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl OpenSim::StateVector::~StateVector(void)" (__imp_??1StateVector@OpenSim@@UEAA@XZ) referenced in function "public: virtual void * __cdecl OpenSim::StateVector::`vector deleting destructor'(unsigned int)" (??_EStateVector@OpenSim@@UEAAPEAXI@Z)
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl OpenSim::Exception::~Exception(void)" (__imp_??1Exception@OpenSim@@UEAA@XZ) referenced in function main$catch$0
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char const * __cdecl OpenSim::Exception::getMessage(void)const " (__imp_?getMessage@Exception@OpenSim@@QEBAPEBDXZ) referenced in function main$catch$0
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl OpenSim::Model::~Model(void)" (__imp_??1Model@OpenSim@@UEAA@XZ) referenced in function main
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl OpenSim::Object::setName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?setName@Object@OpenSim@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function main
3>TugOfWar1_CreateModel.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl OpenSim::Model::Model(void)" (__imp_??0Model@OpenSim@@QEAA@XZ) referenced in function main
3>C:\Users\Juan\Documents\OpenSimWorkspace\ExampleMain\build\Release\TugOfWar1_CreateModel.exe : fatal error LNK1120: 11 unresolved externals
3>
3>Build FAILED.

Not sure what the problem is. Previously I was using visual c++ express and saw a suggestion to not use express, so I uninstalled express and installed visual studio, I deleted everything and started over with cmake and still got the same error message shown above when I try to build with visual studio.

Re: Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 10:27 am
by aymanh
Hi Juan,

What you got are link errors (rather than compilation errors). Likely reasons:
1. Trying to build debug configuration (we distribute only release libraries as the debug libraries are not redistributable per Microsoft and are very dependent on the version of VisualStudio/machine-configuration). Make a release build or relWithDebugInfo.
2. The version of VisualStudio is incompatible with the libraries included in your OpenSim installation. We don't distribute a build with VS2010 Pro libraries, we distribute VC8Pro, VC9Pro, VC10Express. You should be using the VC10Express installer. I've seen this work with VS2010Pro but that's dependent on Microsoft/VisualStudio compatibilities which change over time, however the error you get doesn't seem to be related to this issue.
3. Make sure the project settings created by CMake have the correct library paths and library names from the OpenSim installation that you intend to use.

Hope this helps and please let us know how it goes,
-Ayman

Re: Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 11:20 am
by jrleon
aymanh wrote:Hi Juan,

What you got are link errors (rather than compilation errors). Likely reasons:
1. Trying to build debug configuration (we distribute only release libraries as the debug libraries are not redistributable per Microsoft and are very dependent on the version of VisualStudio/machine-configuration). Make a release build or relWithDebugInfo.

I don't have too much experience with Visual Studio, but I'm pretty sure I did set the Solution Configurations to release or relWithDebugInfo, yet I always get the linker errors.

2. The version of VisualStudio is incompatible with the libraries included in your OpenSim installation. We don't distribute a build with VS2010 Pro libraries, we distribute VC8Pro, VC9Pro, VC10Express. You should be using the VC10Express installer. I've seen this work with VS2010Pro but that's dependent on Microsoft/VisualStudio compatibilities which change over time, however the error you get doesn't seem to be related to this issue.

Like I mentioned previously, I had been using VC10Express, but I still got the Linker errors.

3. Make sure the project settings created by CMake have the correct library paths and library names from the OpenSim installation that you intend to use.

Not sure what I should be checking here.


Hope this helps and please let us know how it goes,
-Ayman

Re: Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 1:11 pm
by aymanh
Hi,

The link line should contain at least the .lib files

osimSimulation.lib
osimActuators.lib
osimCommon.lib
osimAnalyses.lib
osimTools.lib
OpenSim_SimTKcommon.lib
OpenSim_SimTKmath.lib
OpenSim_SimTKsimbody.lib
OpenSim_SimTKlapack.lib
pthreadVC2.lib

And the Additional Library Directories should contain the directory that has these .lib files (usually installDir/sdk/lib)

Please let us know what you find.
-Ayman

Re: Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 2:35 pm
by jrleon
additional dependencies contains:

kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;
osimCommon.lib;
osimSimulation.lib;
osimAnalyses.lib;
osimActuators.lib;
osimTools.lib;
OpenSim_SimTKcommon.lib;
OpenSim_SimTKmath.lib;
OpenSim_SimTKsimbody.lib;
SimTKlapack.lib;
pthreadVC2.lib

Additional Library Directories:
C:/OpenSim2.4.0/sdk/lib;C:/OpenSim2.4.0/sdk/lib/$(Configuration);;C:/OpenSim2.4.0/bin;C:/OpenSim2.4.0/bin/$(Configuration);%(AdditionalLibraryDirectories)

Re: Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 2:46 pm
by aymanh
Hi Juan,

The dependencies look correct as well as the additional library paths (assuming you accepted installation is in the default location C:/OpenSim2.4.0/). Is this the correct install location? and which installer did you run (VC8P, VC9P, VC10E)?

Thanks,
-Ayman

Re: Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 2:57 pm
by jrleon
This is what I had when I ran cmake:

OPENSIM_INSTALL_DIR: C:/OpenSim2.4.0/

Current Generator: Visual Studio 10 Win64

Re: Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 3:03 pm
by aymanh
Thanks Juan,

That explains as we do not distribute 64 bit libraries, you need to use 32 bit libraries instead (even if your machine is win 64).

-Ayman

Re: Visual Studio compilation errors ExampleMain

Posted: Mon Jun 11, 2012 3:39 pm
by jrleon
That was it. Thank you.

Re: Visual Studio compilation errors ExampleMain

Posted: Fri Apr 04, 2014 8:45 pm
by weifeng0715
OpenSim_SimTKlapack.lib
pthreadVC2.lib


VS2010 reports that these two libs do not exist