TORQUE_SHARED confusion
by Tim Pynegar · in Torque 3D Professional · 05/13/2009 (4:20 am) · 15 replies
Hi,
I'm trying to using the StandardMainLoop from within the application. I've removed TORQUE_SHARED from my project ( wizard generated ) and the Torque3d lib project. I'm getting the following build errors.
1>------ Build started: Project: Torque3D, Configuration: Debug Win32 ------
1>Linking...
1> Creating library ../../../game/Torque3D_DEBUG.lib and object ../../../game/Torque3D_DEBUG.exp
1>winWindow.obj : error LNK2019: unresolved external symbol "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z) referenced in function "int __cdecl run(int,char const * *)" (?run@@YAHHPAPBD@Z)
1>../../../game/Torque3D_DEBUG.dll : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Torque\Torque 3D 2009 Beta 1\My Projects\Test\buildFiles\Link\VC2k8.Debug.Win32\Torque3D\BuildLog.htm"
1>Torque3D - 2 error(s), 0 warning(s)
and then in the project itself
3>main.obj : error LNK2019: unresolved external symbol "void __cdecl Platform::restartInstance(void)" (?restartInstance@Platform@@YAXXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl StandardMainLoop::requiresRestart(void)" (?requiresRestart@StandardMainLoop@@SA_NXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl StandardMainLoop::shutdown(void)" (?shutdown@StandardMainLoop@@SAXXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl StandardMainLoop::doMainLoop(void)" (?doMainLoop@StandardMainLoop@@SA_NXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "void __cdecl Platform::AlertOK(char const *,char const *)" (?AlertOK@Platform@@YAXPBD0@Z) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl StandardMainLoop::handleCommandLine(int,char const * *)" (?handleCommandLine@StandardMainLoop@@SA_NHPAPBD@Z) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl StandardMainLoop::init(void)" (?init@StandardMainLoop@@SAXXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>LIBCMTD.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
The Torque3D lib exports the following functions
torque_engineinit
torque_enginetick
torque_enginesignalshutdown
torque_engineshutdown
torque_setwebdeployment
torque_reset
torque_getvariable
torque_setvariable
torque_evaluate
torque_exportstringcallback
torque_addsecurefunction
torque_callsecurefunction
torque_resizewindow
torque_winmain
so i'm wondering how this is meant to fit together or what else i'm meant to do beyond removing TORQUE_SHARED from the application project and Torque3D lib.
Thanks,
Tim.
I'm trying to using the StandardMainLoop from within the application. I've removed TORQUE_SHARED from my project ( wizard generated ) and the Torque3d lib project. I'm getting the following build errors.
1>------ Build started: Project: Torque3D, Configuration: Debug Win32 ------
1>Linking...
1> Creating library ../../../game/Torque3D_DEBUG.lib and object ../../../game/Torque3D_DEBUG.exp
1>winWindow.obj : error LNK2019: unresolved external symbol "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z) referenced in function "int __cdecl run(int,char const * *)" (?run@@YAHHPAPBD@Z)
1>../../../game/Torque3D_DEBUG.dll : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Torque\Torque 3D 2009 Beta 1\My Projects\Test\buildFiles\Link\VC2k8.Debug.Win32\Torque3D\BuildLog.htm"
1>Torque3D - 2 error(s), 0 warning(s)
and then in the project itself
3>main.obj : error LNK2019: unresolved external symbol "void __cdecl Platform::restartInstance(void)" (?restartInstance@Platform@@YAXXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl StandardMainLoop::requiresRestart(void)" (?requiresRestart@StandardMainLoop@@SA_NXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl StandardMainLoop::shutdown(void)" (?shutdown@StandardMainLoop@@SAXXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl StandardMainLoop::doMainLoop(void)" (?doMainLoop@StandardMainLoop@@SA_NXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "void __cdecl Platform::AlertOK(char const *,char const *)" (?AlertOK@Platform@@YAXPBD0@Z) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl StandardMainLoop::handleCommandLine(int,char const * *)" (?handleCommandLine@StandardMainLoop@@SA_NHPAPBD@Z) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl StandardMainLoop::init(void)" (?init@StandardMainLoop@@SAXXZ) referenced in function "int __cdecl TorqueMain(int,char const * *)" (?TorqueMain@@YAHHPAPBD@Z)
3>LIBCMTD.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
The Torque3D lib exports the following functions
torque_engineinit
torque_enginetick
torque_enginesignalshutdown
torque_engineshutdown
torque_setwebdeployment
torque_reset
torque_getvariable
torque_setvariable
torque_evaluate
torque_exportstringcallback
torque_addsecurefunction
torque_callsecurefunction
torque_resizewindow
torque_winmain
so i'm wondering how this is meant to fit together or what else i'm meant to do beyond removing TORQUE_SHARED from the application project and Torque3D lib.
Thanks,
Tim.
#2
S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
This is called from your executable's main.cpp and is the entry point with TorqueMain rght above it being the main loop.. using the torque_ family of exported functions for consistency...
I think this is what you're looking for... at least I hope so... if you need to drill deeper have a look in Engine/source/app/mainLoop.cpp
- Josh
05/13/2009 (1:21 pm)
Have a look at Engine/source/platformWin32/winWindow.cppS32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
This is called from your executable's main.cpp and is the entry point with TorqueMain rght above it being the main loop.. using the torque_ family of exported functions for consistency...
I think this is what you're looking for... at least I hope so... if you need to drill deeper have a look in Engine/source/app/mainLoop.cpp
- Josh
#3
It seems like as it's been put in there that it should be usable however i need some pointers due to the issue above to get it going.
Thanks,
Tim.
05/13/2009 (1:37 pm)
I had a look through these however the issue is that i'd end up changing the engine code and also i'd have to link in my code into the Torque3d lib / dll. The nice thing about the TorqueMain function and using StandardMainLoop from the #ifdef ed out code in the default main.cpp file is that this is all in my game project and i can subsequently from there link into the other C++ modules i'd like to use.It seems like as it's been put in there that it should be usable however i need some pointers due to the issue above to get it going.
Thanks,
Tim.
#4
The new build setup for beta 2 is less confusing as there is no longer a "Torque 3D" project and rather it is named the same as your project... which is the same as the static EXE (as there is no external linking to engine sources in either configuration) with the added benefit of your code + the engine being able to be dynamically loaded and unloaded...
05/13/2009 (2:50 pm)
If you look in the PhysX demo you can see an example project.conf for a static executable... however, for beta 2 all builds now use the DLL configuration.The new build setup for beta 2 is less confusing as there is no longer a "Torque 3D" project and rather it is named the same as your project... which is the same as the static EXE (as there is no external linking to engine sources in either configuration) with the added benefit of your code + the engine being able to be dynamically loaded and unloaded...
#5
So, instead of engine sources and your sources all compiled into an EXE... we have engine source and your sources compiled into a DLL with a small EXE (which is more flexible as the same DLL can be loaded into the web, tools, etc).
05/13/2009 (2:59 pm)
BTW, it would be absolutely preferable to have your code and the engine code in separate code modules... "Game.exe + YourGame.dll + Torque3D.dll" or "YourGame.exe + Torque3D.dll", however this isn't possible with the current console system or without exporting lots of stuff from the DLL... So, instead of engine sources and your sources all compiled into an EXE... we have engine source and your sources compiled into a DLL with a small EXE (which is more flexible as the same DLL can be loaded into the web, tools, etc).
#6
I've created a new template project and changed the project.conf and i've got a couple of issues but it's pretty much the PhysX project but without PhysX.
Do you have an ETA on beta2 as i read on here that you were aiming for 2 weeks between beta1 and beta2 which would put us this week, is this still the case.
Thanks,
Tim.
05/13/2009 (5:20 pm)
k thanks for the info.I've created a new template project and changed the project.conf and i've got a couple of issues but it's pretty much the PhysX project but without PhysX.
Do you have an ETA on beta2 as i read on here that you were aiming for 2 weeks between beta1 and beta2 which would put us this week, is this still the case.
Thanks,
Tim.
#7
all i have found is #ifdef TORQUE_SHARED or #ifndef TORQUE_SHARED?
but where is #define TORQUE_SHARED ?
i have never used conditional compilation directives.
so it looks confusing to me.
is not there should be a #define TORQUE_SHARED ?
01/20/2012 (10:02 am)
actually where TORQUE_SHARED has defined?all i have found is #ifdef TORQUE_SHARED or #ifndef TORQUE_SHARED?
but where is #define TORQUE_SHARED ?
i have never used conditional compilation directives.
so it looks confusing to me.
is not there should be a #define TORQUE_SHARED ?
#8
Hope that is helpful.
Also - if you need to define TORQUE_SHARED for your build you can do so in torqueConfig.h. CTRL-F to search, but mostly looks like it's used in winWindow.cpp and main.cpp - check over those blocks to see if you want them.
01/20/2012 (11:56 am)
Quote:- Michael Perry
It all starts in int TorqueMain, which is defined in Engine/source/platformWin3d/winWindow.cpp has this function:
The main purpose of that function is to call int torque_enginetick(), which is defined in Enginesourcecinterfacecinterface.cpp
That function will call the "real" main loop, which is StandardMainLoop::doMainLoop() defined in EnginesourceappmainLoop.cpp.
That function is what is responsible for executing threads, signaling the event processor and other core features. The process and signal system is what drives the rest of the engine.
Hope that is helpful.
Also - if you need to define TORQUE_SHARED for your build you can do so in torqueConfig.h. CTRL-F to search, but mostly looks like it's used in winWindow.cpp and main.cpp - check over those blocks to see if you want them.
#9
but the thing that i could not find out where TORQUE_SHARED has benn defined!!!!!!!!!
i have searched torqueConfig.h and vs2010 solution of my project.no where i have found it.
a simple summery of main.cpp and winWindow.cpp is this:
//////////main.cpp
#ifdef TORQUE_SHARED
ifdef WIN32
int (*torque_winmain)( HINSTANCE hInstance, HINSTANCE h, LPSTR lpszCmdLine, int nShow) = NULL;
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow){........}
#endif // WIN32
S32 TorqueMain(S32 argc, const char **argv){..........}
#endif //TORQUE_SHARED
winWindow.cpp
#ifndef TORQUE_SHARED
extern S32 TorqueMain(S32 argc, const char **argv);
S32 main(S32 argc, const char **argv){............}
S32 PASCAL WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32){...........}
#else //TORQUE_SHARED
int TorqueMain(int argc, const char **argv){...........}
S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32){...................}
#endif
by debugging i have found out comiler goes through
1st
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow)//----main.cpp
then,
S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)//------winWindow.cpp
finally.
int TorqueMain(int argc, const char **argv)//-----------winWindow.cpp
it always going into #ifdef TORQUE_SHARED blocks.
not #ifndef TORQUE_SHARED.
so somewhere TORQUE_SHARED has been defined.
is it in code?
where?
01/20/2012 (5:26 pm)
i already have figured it out..but the thing that i could not find out where TORQUE_SHARED has benn defined!!!!!!!!!
i have searched torqueConfig.h and vs2010 solution of my project.no where i have found it.
a simple summery of main.cpp and winWindow.cpp is this:
//////////main.cpp
#ifdef TORQUE_SHARED
ifdef WIN32
int (*torque_winmain)( HINSTANCE hInstance, HINSTANCE h, LPSTR lpszCmdLine, int nShow) = NULL;
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow){........}
#endif // WIN32
S32 TorqueMain(S32 argc, const char **argv){..........}
#endif //TORQUE_SHARED
winWindow.cpp
#ifndef TORQUE_SHARED
extern S32 TorqueMain(S32 argc, const char **argv);
S32 main(S32 argc, const char **argv){............}
S32 PASCAL WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32){...........}
#else //TORQUE_SHARED
int TorqueMain(int argc, const char **argv){...........}
S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32){...................}
#endif
by debugging i have found out comiler goes through
1st
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow)//----main.cpp
then,
S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)//------winWindow.cpp
finally.
int TorqueMain(int argc, const char **argv)//-----------winWindow.cpp
it always going into #ifdef TORQUE_SHARED blocks.
not #ifndef TORQUE_SHARED.
so somewhere TORQUE_SHARED has been defined.
is it in code?
where?
#10
that is what i looking for.thanks Nathan.
i was thinking something like that.
but the problem was i do no know any advance things on visual studio.
01/20/2012 (5:39 pm)
http://www.garagegames.com/community/forums/viewthread/129482/1#comment-823730Quote:
Quick Update: TORQUE_SHARED macro is already defined for you in the app project's Configuration Properties -> C/C++ -> Preprocessor: Preprocessor Definitions field.
that is what i looking for.thanks Nathan.
i was thinking something like that.
but the problem was i do no know any advance things on visual studio.
#11
I had to run my code in a separate thread inside Python to get any kind of speed from the Python code. It went from literally 10K cycles to millions between T3D main loop iterations. So if you find your code acting really slow it is because the main loop takes so long between iterations. I would test this first to see if it will provide the speed you need. I basically only use the main loop, which I call in Python, for non-critical updates. Everything else is a callback either in Python or T3D.
01/20/2012 (11:13 pm)
While working with extending Python with T3D I found that if you run after the main loop your code will be slow. The call to the T3D engine takes a while before it releases control back to the loop. If you need speed I would recommend a callback or something else. Maybe a new object. Otherwise you will be disappointed with how often your code gets called. UNLESS, you run in a separate thread. I had to run my code in a separate thread inside Python to get any kind of speed from the Python code. It went from literally 10K cycles to millions between T3D main loop iterations. So if you find your code acting really slow it is because the main loop takes so long between iterations. I would test this first to see if it will provide the speed you need. I basically only use the main loop, which I call in Python, for non-critical updates. Everything else is a callback either in Python or T3D.
#12
And I guess it's good that TORQUE_SHARED is defined somewhere if that's the intent, but I'd rather see it in a source file than in the project preprocessor settings somewhere. I would actually like all of those directives and defines called out explicitly just for ease of use.
01/21/2012 (7:34 pm)
@Frank - so, basically adding any other VM we'd probably want to follow that methodology? Say, adding the parallel Lua trick that someone mentioned recently?And I guess it's good that TORQUE_SHARED is defined somewhere if that's the intent, but I'd rather see it in a source file than in the project preprocessor settings somewhere. I would actually like all of those directives and defines called out explicitly just for ease of use.
#13
Since it is something that changes from project to project, it is a lot easier to tweak your Project Generator config file than to have the Project Generator cleanly update a source file.
01/24/2012 (1:01 pm)
It is set in the preprocessor defines by the Project Generator.Since it is something that changes from project to project, it is a lot easier to tweak your Project Generator config file than to have the Project Generator cleanly update a source file.
#14
09/28/2012 (6:08 pm)
[double post]
#15
almost done.
now i need to remove dependency on dll file,that means static binding,
am i correct?
if yes then how to do that?
i have tried to set configuration type to exe(from configuration properties->general) .
but it shows this error:
"Error 51 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup E:Torque 3D 1.2My Projectsexe1buildFilesVisualStudio 2010projectsLIBCMT.lib(wincrt0.obj)"
?
may be i need to change this lines:
but to what?
09/28/2012 (6:11 pm)
i am trying to make some tools based on t3d source code.almost done.
now i need to remove dependency on dll file,that means static binding,
am i correct?
if yes then how to do that?
i have tried to set configuration type to exe(from configuration properties->general) .
but it shows this error:
"Error 51 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup E:Torque 3D 1.2My Projectsexe1buildFilesVisualStudio 2010projectsLIBCMT.lib(wincrt0.obj)"
?
may be i need to change this lines:
GetModuleFileNameA(NULL, filename, 4096); filename[strlen(filename)-4] = 0;//?????????????? sprintf(gameLib, "%s.dll", filename); HMODULE hGame = LoadLibraryA(gameLib);
but to what?
Torque 3D Owner Tim Pynegar
Thanks,
Tim.