0

I am working with Qt and Cryengine in visual studios. I am very new to large projects such as this one, but I am nearly to the point of actually adding something to this engine. My code compiles piece by piece, but when I try to compile my "Indie Game" project I get linking errors that after researching I still have no idea how to solve. I know the errors relate to my code InventoryGUI, because when I remove that file the project compiles fine with no linking errors.

This is my InventoryGUI code and the error that is displayed when trying to build Indie Game http://imgur.com/hzmGdvH

This is the header file that it includes. http://imgur.com/o22GHXg

I appreciate any help you guys can give on this. Of course, if you need to see different parts of my code, let me know and I will post it as well.

Thanks

Edit: Forgot to add that the function "createInventory()" calls the function InventoryGUI from a different project. I believe going between projects is very likely the cause of the errors.

user2453703
  • 33
  • 1
  • 2
  • 4

1 Answers1

0

if InventoryGUI class is defined in a shared library ("dll") and used in an executable, then you have to export its symbols (on Windows build that is). so try something like :

#ifdef WIN32
#   ifdef MY_LIB_EXPORTS
#      define MY_LIB_DLL   __declspec(dllexport)
#   else
#      define MY_LIB_DLL   __declspec(dllimport)
#   endif
#else
#   define MY_LIB_DLL
#endif

class MY_LIB_DLL InventoryGUI
{
...
};

Then, the library defining InventoryGUI should have defined MY_LIB_EXPORTS. For example if you use pro files system, it would look like

DEFINES += MY_LIB_EXPORTS

Other projects should not. Check if there is a similar mechanism for the other classes of the library.

azf
  • 2,179
  • 16
  • 22
  • I'm sorry totem. I don't know very much about the build process and integrating large project like this. I got a little lost with that, although I think I understand part of what you are saying. First off, InventoryGUI is defined in my Qt project which is compiled as a .exe and IndieGame is compiled as a .dll. That code you gave me. I'm guessing I need to put that down in the Qt in inventorygui.cpp? And I'm sorry, but I do not follow what you are saying about the library defining InventoryGUI. – user2453703 Jun 13 '13 at 20:07
  • A thought just occurred to me. As I was saying, this is my first time working with a big project like this so I was just going with what was given to me by default. Is it really best to be using functions defined in an executable inside a dll? Should I change my Qt project to a .dll? – user2453703 Jun 13 '13 at 20:12
  • @user2453703 it's surely not ok to use exe functions in a dll :D consider doing the opposite instead. Exposing symbols (as `__declspec(dllexport)` does) is for DLL code being used in another lib or executable – azf Jun 14 '13 at 18:11