Compiling problems on mac

guido

27-08-2010 09:36:17

I'm running into several issues when I try to compile the latest version of MyGUI (3.1.0 from trunk on I think it was monday) on MacOSX. Many came, so more will follow... I hope you won't mind if I keep posting the errors I am working on. I think I started debuggin on monday? About 3 days of spare time ): I'd really like to use MyGUI though.

Right now I have a linking error.


[ 40%] Built target MyGUIEngine
[ 43%] Built target MyGUI.OgrePlatform
[ 44%] Built target Common
Linking CXX shared library ../../lib/Plugin_StrangeButton.framework/Versions/A/Plugin_StrangeButton
Undefined symbols:
"MyGUI::Singleton<MyGUI::FactoryManager>::msInstance", referenced from:
__ZN5MyGUI9SingletonINS_14FactoryManagerEE10msInstanceE$non_lazy_ptr in Plugin.cpp.o
"MyGUI::Singleton<MyGUI::PluginManager>::msInstance", referenced from:
__ZN5MyGUI9SingletonINS_13PluginManagerEE10msInstanceE$non_lazy_ptr in Plugin_Export.cpp.o
"MyGUI::Singleton<MyGUI::FactoryManager>::mClassTypeName", referenced from:
__ZN5MyGUI9SingletonINS_14FactoryManagerEE14mClassTypeNameE$non_lazy_ptr in Plugin.cpp.o
"MyGUI::Singleton<MyGUI::PluginManager>::mClassTypeName", referenced from:
__ZN5MyGUI9SingletonINS_13PluginManagerEE14mClassTypeNameE$non_lazy_ptr in Plugin_Export.cpp.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [lib/Plugin_StrangeButton.framework/Versions/A/Plugin_StrangeButton] Error 1
make[1]: *** [Plugins/Plugin_StrangeButton/CMakeFiles/Plugin_StrangeButton.dir/all] Error 2
make: *** [all] Error 2

guido

27-08-2010 12:54:15

Where I am so far...

The plugin makes use of MyGUI:: Singleton<T> at ./MyGUIEngine/include/MyGUI_Singleton.h. Because it is a template class the preprocessor has to instantiate the template into a class before the compiler can compile it. So I *think* the plugin, compiled as a library, is missing this header when it is created.

The plugin is made by the mygui_plugin function which is called as CMake adds the directories in the path ./Plugins/Plugin_StrangeButton.

This mygui_plugin function is defined in ./CMake/Utils/MyGUIConfigTargets.cmake as


#setup Plugin builds
function(mygui_plugin PROJECTNAME)
include_directories(.)

# define the sources
include(${PROJECTNAME}.list)

add_definitions("-D_USRDLL -DMYGUI_BUILD_DLL")
add_library(${PROJECTNAME} ${MYGUI_LIB_TYPE} ${HEADER_FILES} ${SOURCE_FILES})
set_target_properties(${PROJECTNAME} PROPERTIES SOLUTION_FOLDER "Plugins")
add_dependencies(${PROJECTNAME} MyGUIEngine)
target_link_libraries(${PROJECTNAME} MyGUIEngine)

mygui_config_lib(${PROJECTNAME})

install(FILES ${HEADER_FILES}
DESTINATION include/MYGUI
)
endfunction(mygui_plugin)


It is strange that
add_library(${PROJECTNAME} ${MYGUI_LIB_TYPE} ${HEADER_FILES} ${SOURCE_FILES})
passes ${HEADER_FILES} which is defined in ./MyGUIEngine/MyGUIEngine.list and contains the header of MyGUI_Singleton.h...

So why isn't it linking? Could it be that ${HEADER_FILES} was replaced with its values when it was defined, which is before MyGUIEngine.list assigned the list of header files to it? So later, when mygui_plugin is invoked, the function does not contain any headers at all?

I have to rush to university now and get some stuff done. But when I return I am going to learn how CMake deals with these vars when functions are defined and try to fix this issue.

guido

27-08-2010 21:17:41

So I knocked out all the demos and tools unittests, and it completed compiling. Then I link to my own testing application... I get the same linking problem again. This is the fourth day of figuring out how I can compile MyGUI... It is getting real frustrating...

Please help (and yes this is the latest build from the svn)



rning __ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_ERKS6_S8_.eh has different visibility (1) in ./Frameworks/libOIS.a(MacHIDManager.o) and (2) in /var/folders/s-/s-8s9K5yFy0X7r3e8srlWU+++TI/-Tmp-//cc4KUoOl.o
Undefined symbols:
"MyGUI::Singleton<MyGUI::RenderManager>::mClassTypeName", referenced from:
__ZN5MyGUI9SingletonINS_13RenderManagerEE14mClassTypeNameE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreRenderManager.cpp.o)
"MyGUI::Singleton<MyGUI::DataManager>::mClassTypeName", referenced from:
__ZN5MyGUI9SingletonINS_11DataManagerEE14mClassTypeNameE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreDataManager.cpp.o)
__ZN5MyGUI9SingletonINS_11DataManagerEE14mClassTypeNameE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreTexture.cpp.o)
"MyGUI::Singleton<MyGUI::LayerManager>::mClassTypeName", referenced from:
__ZN5MyGUI9SingletonINS_12LayerManagerEE14mClassTypeNameE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreRenderManager.cpp.o)
"MyGUI::Singleton<MyGUI::RenderManager>::msInstance", referenced from:
__ZN5MyGUI9SingletonINS_13RenderManagerEE10msInstanceE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreRenderManager.cpp.o)
__ZN5MyGUI9SingletonINS_13RenderManagerEE10msInstanceE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreRTTexture.cpp.o)
"MyGUI::Singleton<MyGUI::LayerManager>::msInstance", referenced from:
__ZN5MyGUI9SingletonINS_12LayerManagerEE10msInstanceE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreRenderManager.cpp.o)
"MyGUI::Singleton<MyGUI::DataManager>::msInstance", referenced from:
__ZN5MyGUI9SingletonINS_11DataManagerEE10msInstanceE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreRenderManager.cpp.o)
__ZN5MyGUI9SingletonINS_11DataManagerEE10msInstanceE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreDataManager.cpp.o)
__ZN5MyGUI9SingletonINS_11DataManagerEE10msInstanceE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreTexture.cpp.o)
"MyGUI::Singleton<MyGUI::Gui>::msInstance", referenced from:
__ZN5MyGUI9SingletonINS_3GuiEE10msInstanceE$non_lazy_ptr in libMyGUI.OgrePlatform.a(MyGUI_OgreRenderManager.cpp.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [ExecutableBase/main2.out] Error 1
Macintosh-78:Zin guidocalvano$

Altren

27-08-2010 22:47:09

So does demos and tools compiles or not? If yes then compare preprocessor options and linker options.

guido

28-08-2010 02:01:05

They didn't. But I tried out some other version I had and I got it to work. Too tired now to talk about it. Have to sleep, there is a wedding tomorrow, so I'll explain sunday.

In five minutes I'll be in a coma...

guido

28-08-2010 02:06:42

1. fdiagnostic-show... removed
2. Ogre.framework paths hard coded
3. appended boost to Ogre lib and header vars
4. turned of compiling of demos tools and unit tests

this list could be incorrect I have to check to be sure, but not now
too tired

guido

28-08-2010 02:08:04

Yea!!!!

I got the one with multi line textboxes, coloured strings and animation...

woooohoooooooo!!!!

Altren

28-08-2010 02:47:58

Glad that it finally works.
You can create svn patch to see all changes. Also show this patch to me and I'll try to fix CMake scripts to make it working without manual changes.

guido

31-08-2010 22:26:32

In what I think is latest stable build I did this;


/CMake/packages/FindOGRE_Old.cmake


# Find OGRE includes and library
#
# This module defines
# OGRE_INCLUDE_DIR
# OGRE_LIBRARIES, the libraries to link against to use OGRE.
# OGRE_LIB_DIR, the location of the libraries
# OGRE_FOUND, If false, do not try to use OGRE


# Hack to allow linking locally to Zin

set (OGRE_INCLUDE_DIR "~/Tree/Data/Projecten/Zin/Zin/Frameworks/Ogre.framework/Headers" "~/Tree/Data/Projecten/Zin/Zin/Frameworks/boost_1_42" ) # ${OGRE_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
set (OGRE_LIB_DIR "~/Tree/Data/Projecten/Zin/Zin/Frameworks/Ogre.framework/" "~/Tree/Data/Projecten/Zin/Zin/Frameworks/" "../Frameworks/boost_1_42/")
set (OGRE_LIBRARIES "Ogre" "boost_1_42/boost_thread-xgcc40-mt-1_42" "boost_date_time-xgcc40-mt-1_42" )
set (OGRE_FOUND TRUE )



if( FALSE )

# Try to find framework first on Mac OS X
if (APPLE)
MACRO (find_framework fwk)
find_library(${fwk}_LIBRARY ${fwk})
if (${fwk}_LIBRARY)

guido

31-08-2010 22:30:36

in ./CMakeLists.txt




######################################################################
# Provide user options to customise the build process
######################################################################

# Customise what to build
option(MYGUI_STATIC "Static build" FALSE)
option(MYGUI_USE_FREETYPE "Use freetype for font rendering" TRUE)
option(MYGUI_DONT_USE_OBSOLETE "Remove obsole functions from build" FALSE)

set(MYGUI_RENDERSYSTEM 2 CACHE STRING
"Specify the Render System. Possible values:
1 - Direct3D 9
2 - Ogre
3 - OpenGL"
)

option(MYGUI_BUILD_SAMPLES "Build MyGUI demos" FALSE)
option(MYGUI_BUILD_PLUGINS "Build MyGUI plugins" TRUE)
option(MYGUI_BUILD_TOOLS "Build the tools" FALSE)
option(MYGUI_BUILD_TESTS "Build the unit tests & TestApp" FALSE)
option(MYGUI_BUILD_WRAPPER "Build the wrapper" FALSE)

option(MYGUI_INSTALL_SAMPLES "Install MyGUI demos." FALSE)
option(MYGUI_INSTALL_TOOLS "Install MyGUI tools." FALSE)
option(MYGUI_INSTALL_DOCS "Install documentation." FALSE)
option(MYGUI_INSTALL_MEDIA "Install media files." FALSE)
option(MYGUI_INSTALL_SAMPLES_SOURCE "Install samples source files." FALSE)
cmake_dependent_option(MYGUI_INSTALL_PDB "Install debug pdb files" FALSE "MSVC" FALSE)
option(MYGUI_FULL_RPATH "Build executables with the full required RPATH to run from their install location." FALSE)
option(MYGUI_STANDALONE_BUILD "Generate build files that do not reference CMake (should be used only from Scripts/prepareRelease.py)" FALSE)
MARK_AS_ADVANCED(MYGUI_STANDALONE_BUILD)

set(MYGUI_SAMPLES_INPUT 1 CACHE STRING
"Specify the Input Manager for samples. Possible values:
1 - OIS
2 - Win32
3 - Win32 (Mouse) + OIS (Keyboard)"
)

guido

31-08-2010 22:35:17

These hacks seem like a very bad solution.

I think it is better to create some file where all these ogre values can be set manually. But this is my first exposure to cmake so I don't think I am the perfect candidate for the job.

Maybe make the file such that it, if defined, it will prevent searching for boost and ogre. The reason things went wrong for me, probably, was that I didn't have Ogre installed in the default directory but inside my project dir.

Altren

31-08-2010 23:39:17

Oh, did you tried to set OGRE_HOME variable in CMake? That is what you should do when CMake can't find some library.

Also I see that you changed options in cmake file. You shouldn't do that. Better use CMake gui, or if you use command line tool run cmake with -D option:
cmake -DOGRE_HOME=/path/to/Ogre -DMYGUI_BUILD_SAMPLES=FALSEand so on.

psquare

13-11-2010 06:28:57

I am sorry to bump this old thread, but I am having the same link errors as the 1st post here from the OP.

This is for the samples.

@Guido: What did you do to get rid of these errors?

Altren

13-11-2010 12:20:20

You should download newer sources - MyGUI 3.0.3 https://my-gui.svn.sourceforge.net/svnr ... s/MyGUI3.0 (svn link)
But I'm not sure that I included all Mac OSX related fixes in it, so you can try dev version from trunk https://my-gui.svn.sourceforge.net/svnroot/my-gui/trunk (svn link)

psquare

13-11-2010 12:31:33

I am using the latest from trunk :-(

Altren

13-11-2010 14:42:51

Post your errors log please.

psquare

13-11-2010 15:38:48

The errors are exactly the same as the first post on this thread.

Each reference of Instance and TypeName for the singleton classes (input manager, etc) cannot be resolved.

I am away from my dev environment at the moment. I'll post the exact errors later. But there's not much difference really from the errors in the first post. Although, the OP is trying to build the strange button plugin. I get these errors for all samples I tried (ItemBox, Color, etc). I didn't try the strange button plugin.

psquare

14-11-2010 10:14:51

Hi Altren,
Here you go:

Altren

14-11-2010 12:44:00

What version of gcc do you have?

Also try to do next change, replace in MyGUI_Singleton.h, line 30:
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC || MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
template <class T>
class Singleton
#else
template <class T>
class MYGUI_EXPORT Singleton
#endif
with#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
template <class T>
class Singleton
#else
template <class T>
class MYGUI_EXPORT Singleton
#endif
and then rebuild everything.

psquare

14-11-2010 15:32:26

The used compiler as per xcode is gcc 4.2.

Using 4.0 doesn't help. I tried your fix, I still get the same errors. I tried other things like not hiding symbols at all (in xcode settings), etc too.

Interestingly, I am able to reproduce the same problem in a standalone app/lib. The lib defines a singleton and the app uses it. I do think its a gcc visibility/template specialization problem though, because with some changes I can fix that unresolved error by forward declaring, etc, similar to here:

http://gcc.gnu.org/ml/gcc-help/2008-02/msg00116.html

However, I can't do the same in MyGUI.

psquare

17-11-2010 11:27:05

An update:

I was able to get down the linker errors from 20 down to just 4 by:

-Defining visibility like how Ogre does it, in MyGUI_Singleton.h:

# pragma GCC visibility push(default)
namespace MyGUI
{
....
} // namespace MyGUI
# pragma GCC visibility pop


-Declare and define getClassTypeName, getInstancePtr and getInstance for all the singletons.

I am just getting these 4 errors now though:



Any ideas how to fix these? Interestingly, both the OgreRenderManager and OgreDataManager inherit from a class, which already inherits from a Singleton.

psquare

18-11-2010 10:00:58

Bump :-(

psquare

19-11-2010 14:39:14

Ok. As it turns out, the above linker errors disappear if I compile MyGUI as a static lib, in which case both the engine and the platform lib are static, probably some template stuff that I couldn't find information about.

I am now able to run MyGUI on the Mac.