Building CEGUI 0.8 with MSVC. dllimport problems

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI Team, CEGUI Tools Developer, CEGUI MVP

Building CEGUI 0.8 with MSVC. dllimport problems

Postby frarees » Mon Feb 13, 2012 12:18 pm

I want a dynamic build. Using MSVC, I get those errors:

Code: Select all
Warnings: most warnings regarding "inconsistent DLL-binding"


Code: Select all
deps\cegui\cegui\src\RendererModules\Ogre\Texture.cpp(50): error C2491: 'CEGUI::OgreTexture::d_textureNumber' : definición de miembro de datos estático dllimport no permitida


I think this problem was also reported here, but still present?
frarees
Not too shy to talk
Not too shy to talk
 
Posts: 30
Joined: Wed Feb 01, 2012 5:18 pm

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby CrazyEddie » Tue Feb 14, 2012 7:56 am

I need to start the reply by saying that I do not use MSVC or Windows for development purposes (neither does Kulik). Generally the most I do is basic test compiles, and this means that a lot of the time, options and configurations not enabled by a default system install using the basic dependencies, are not tested very often at all on this platform. This said, I had a general belief that no issues existed that prevented a successful build. Since Ogre is one of the most popular renderer choices, I'm surprised the issue has not been raised previously (I wonder if perhaps it was broken by a recent change?)

I visually checked the code and parts of the build system regarding this and could not see any obvious issues. I looked at the fixes I applied for this issue when it affected the Irrlicht renderer, and there is no correlation here - from what I can tell by looking at it, the macro that controls the import/export is correctly set for the Ogre renderer.

Please supply the exact version of MSVC++ that you are using (including details of any service packs and runtime updates), provide the precise changeset that you are working with, and confirm that you have no local modifications. I will then try to run a test compile on that version of the code sometime later this week.

CE.
User avatar
CrazyEddie
CEGUI Project Lead
 
Posts: 6753
Joined: Wed Jan 12, 2005 12:06 pm
Location: England

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby frarees » Tue Feb 14, 2012 3:55 pm

My friend who is actually working on Windows is having that problem. He said me he's working on Windows 7 SP1, with Visual Studio 10 Pro. He's compiling everything via CMake and the ant plugin called cmakeant (the one we're maintaining here (if it helps).

He told me that he thinks that when it compiles, it's not defining the export macros (CEGUIOGRERENDERER_EXPORTS in our case, but he says that it may not work for any renderer). He says that if he manually defines the macro, everything works properly.

I hope it helps, and soon gets fixed :)
frarees
Not too shy to talk
Not too shy to talk
 
Posts: 30
Joined: Wed Feb 01, 2012 5:18 pm

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby CrazyEddie » Tue Feb 14, 2012 4:00 pm

The macro definitely works ok for both the OpenGL renderers and all three Direct3D renderers. It should also work for Ogre, since it's using the exact same technique. This said, I will confirm one way or the other by the end of this week.

CE.
User avatar
CrazyEddie
CEGUI Project Lead
 
Posts: 6753
Joined: Wed Jan 12, 2005 12:06 pm
Location: England

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby frarees » Wed Feb 15, 2012 10:05 pm

I'm getting quite crazy about all of that. Then, I've found that. It seems it's not a CEGUI problem but VS linker's. Does it makes sense? What can we do?

Thanks.
frarees
Not too shy to talk
Not too shy to talk
 
Posts: 30
Joined: Wed Feb 01, 2012 5:18 pm

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby CrazyEddie » Mon Feb 20, 2012 11:35 am

I managed to test the build of the OgreRenderer this morning using MSVC++, and it works fine with a generic build.

I have no idea about anything in that link you posted, it started rambling about DLL this and static lib that, and around that time my eyes glazed over. As already stated, I do not do development on Windows other than to test that it builds and that the basics work.

CE.
User avatar
CrazyEddie
CEGUI Project Lead
 
Posts: 6753
Joined: Wed Jan 12, 2005 12:06 pm
Location: England

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby frarees » Wed Feb 22, 2012 11:54 am

We still could not build it. Now we're having problems linking GLFW and findind dependencies on Release (and of course on Debug, but we talked about that, so we're not creating debug versions anyway). FindX.cmake modules doesn't work properly for us.

If it works for you, can you please refer me to the set of CMAKE arguments you're passing? All the information provided can be crucial. We're trying to get a compiled version for weeks, without result (having to manually patch things, etc).
frarees
Not too shy to talk
Not too shy to talk
 
Posts: 30
Joined: Wed Feb 01, 2012 5:18 pm

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby CrazyEddie » Wed Feb 22, 2012 12:43 pm

I've been working quite a bit on the deps yesterday and this morning. Later today there will be a beta 5 package uploaded. I've addressed a couple of the issues you've raised (in the deps and in cegui), and also added a condition to stop people trying to build the deps package on platforms other than Win32 and OS X, since the deps are not intended for other platforms, and we will not support people who try to do that.

In doing the work I have, I have tested things quite extensively, on MSVC++ 10 and also on OS X (using various generators and compiler combinations). Aside from the fact I've yet to test things like static builds, and variations on that theme, I experience no major issues building at all (there are some niggling issues on OS X related to Xcode 4.3 and CMake compatibility, I think you're likely aware of those).

As for CMake args, I do not pass any (except CMAKE_BUILD_TYPE when testing Debug/Release with "Unix Makefiles" targets). If it's not finding the dependencies, it's most likely because they're not in the right place. By default, on OSX and Win32, CMake will look in srcroot/dependencies - i.e the directory 'dependencies' created when building the dependencies package should be copied (or symlinked) into the root source dir. You could move it elsewhere, and then set CMAKE_PREFIX_PATH to wherever that 'dependencies' directory exists. If you're using OS X or Win32 and you're trying to use a directory layout other than what we provide in that 'dependencies' directory, then that's something we will not support.

CE.
User avatar
CrazyEddie
CEGUI Project Lead
 
Posts: 6753
Joined: Wed Jan 12, 2005 12:06 pm
Location: England

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby frarees » Wed Feb 22, 2012 6:41 pm

I'm going to check them. I'm on OSX now, and fails installing the demos. I'll try more options and post the results here. Thanks btw!! :D
frarees
Not too shy to talk
Not too shy to talk
 
Posts: 30
Joined: Wed Feb 01, 2012 5:18 pm

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby CrazyEddie » Wed Feb 22, 2012 11:02 pm

I have uploaded a series of videos that show the entire process, from downloading the files, through building them, to running a couple of the finished apps. It's quite long and boring, but still...

http://www.youtube.com/watch?v=VZkfV2mk ... p_play_all

CE.
User avatar
CrazyEddie
CEGUI Project Lead
 
Posts: 6753
Joined: Wed Jan 12, 2005 12:06 pm
Location: England

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby frarees » Thu Feb 23, 2012 7:37 pm

Really nice, gotta check them out. However, I'm not experiencing problems on UNIX platforms but Windows. (CEGUI works great in both Linux & OSX systems).

The problem is when compiling for MSVC. My friend tested every configuration, and came up with this:

1) works:
CEGUI-DEPS : Release
CEGUI : Release

2) doesn't work: can't find deps
CEGUI-DEPS : Debug
CEGUI : Debug

3) works:
CEGUI-DEPS : Debug & deleting _d from each resulting lib
CEGUI : Debug

4) works:
CEGUI-DEPS : Debug & deleting _d commenting out the sentence set(CMAKE_DEBUG_POSTFIX _d)
CEGUI : Debug

5) doesn't work: can't find deps
CEGUI-DEPS : Release
CEGUI : Debug

6) works:
CEGUI-DEPS : Release & deleting _d commenting out the sentence set(CMAKE_DEBUG_POSTFIX _d)
CEGUI : Debug

Seems like a small (but disturbing) trouble managing library names and this stuff. What do you think?
frarees
Not too shy to talk
Not too shy to talk
 
Posts: 30
Joined: Wed Feb 01, 2012 5:18 pm

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby CrazyEddie » Fri Feb 24, 2012 7:48 am

I think the issue is with the fact that to build the debug configuration you basically need both debug and release versions of the dependencies built. I already mentioned this once, and it's a situation that will almost certainly not change (though I'm considering some further tweaks to make it harder for people to make dumb mistakes - watch this space, as they say ;)). It's not that hard to build the two configurations in most cases, if you are using the IDE you can use the batch build facility, and have a cup of coffee while it does it's thing. If you are at the command line you can do:
Code: Select all
msbuild ALL_BUILD.vcxproj /v:q /t:Build /p:Configuration=Debug

followed by:
Code: Select all
msbuild ALL_BUILD.vcxproj /v:q /t:Build /p:Configuration=Release

And then a similar approach can be used to build CEGUI itself once the built dependencies have been moved/copied into place (personally, in my test environment, I create a junction from 'dependencies' in the build location to 'cegui_mk2/dependencies'.

If you are using the nmake/jom makefile generator, then things are slightly muddied, since you still need both sets of dependency libs built, even though you're only specifying one configuration as the build type per cmake invocation. While I acknowledge that this is not perfect (and likely never will be), the fact is that on the Windows platform you will, in 99% of cases, be needing both configurations built, for the reason highlighted in my advise that follows.

I should take this opportunity to advise that when using MSVC++ (and perhaps other compilers on Windows, too), you should never, ever link Release configuration code to libraries built using the Debug configuration (or vice-versa). While the linker may allow that to happen, the resulting binaries will be linked with two separate c/c++ runtimes, as well as having other inconsistencies, both scenarios will invariably lead to unstable behaviour. This is not a CEGUI specific thing, it applies across the board to virtually all components that are not part of the core windows libs.

CE.
User avatar
CrazyEddie
CEGUI Project Lead
 
Posts: 6753
Joined: Wed Jan 12, 2005 12:06 pm
Location: England

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby frarees » Fri Feb 24, 2012 11:11 am

I think the issue is with the fact that to build the debug configuration you basically need both debug and release versions of the dependencies built.


So I have to generate them twice (release & debug for CEGUIDEPS)? I don't get why should I do this, it's weird to me. I thought if you were building a library in a specific config, their dependencies should be built in that config too. May sound quite noobish, but why this should be done?

What we're actually doing is a bit different. We're managing a CMake build, and using CEGUI via it's ExternalProject capabilities. Our configuration looks somehow like this:

Code: Select all
EXTERNALPROJECT_ADD(CEGUIDEPS SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/cegui/dependencies" CMAKE_ARGS
  -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
  -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/output-ceguideps
  INSTALL_COMMAND "" # no install step
)
EXTERNALPROJECT_GET_PROPERTY(CEGUIDEPS BINARY_DIR)
SET(CEGUI_BUILT_DEPENDENCIES_DIR ${BINARY_DIR}/dependencies)

EXTERNALPROJECT_ADD(CEGUI DEPENDS CEGUIDEPS SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/cegui" CMAKE_ARGS
  -DCMAKE_PREFIX_PATH=${CEGUI_BUILT_DEPENDENCIES_DIR}
  -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
  -DCEGUI_SAMPLES_ENABLED:BOOL=OFF
  -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/output-cegui
)


With that configuration, everything seems to work, but you're generating both dynamic and static deps, and CEGUI is build dynamic. If we "play" with the definitions/variables you grant us (like CEGUI_BUILD_SHARED_LIBS_WITH_STATIC_DEPENDENCIES), things get messed up (linkage errors, dependencies not being built, dllimport/dllexport problems, etc). Now with beta5 deps and latest CEGUI branch, things seem quite stable, but still inconsistent when not using the default configuration (I'm talking just about Windows, I wasn't experiencing any of those problems on my Mac, neither in my friend's Linux system).
frarees
Not too shy to talk
Not too shy to talk
 
Posts: 30
Joined: Wed Feb 01, 2012 5:18 pm

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby CrazyEddie » Fri Feb 24, 2012 11:17 am

I have pushed some new changes to the way dependencies are detected. I do not know if it will address all possible scenarios (probably not, I'm only really interested in the most common scenarios). I'm aware of another issue relating to changing options and cached variable values that I will try to solve in the coming weeks (it will likely be much quicker, but the release is not expected until the 2nd half of the year - and not all issues will take immediate priority. In fact there are a lot more important issues that need fixing in the library itself before we can consider releasing)

Edit:
The last line in parenthesis sounds a lot more terse / harsh than I intended. I mean to say that, of course, given the large number of outstanding jobs to be done before we can release, some issues will invariably be done later than some others. But, with some fortune, when the release is made, the majority of the issues should be fixed. This statement should also not be taken as meaning to discourage people reporting issues, since without people reporting issues, we would not know about them :D

CE.
User avatar
CrazyEddie
CEGUI Project Lead
 
Posts: 6753
Joined: Wed Jan 12, 2005 12:06 pm
Location: England

Re: Building CEGUI 0.8 with MSVC. dllimport problems

Postby frarees » Fri Feb 24, 2012 11:35 am

I fully understand that pose, don't worry :wink:

We're working hard to make this work, and we know it's quite unstable right now (way more unstable if we keep playing with every variable available). I'm going to check those changes now, and I'll let you know what I do get.

Btw, thanks for being active on that. It means so much for me and my team!
frarees
Not too shy to talk
Not too shy to talk
 
Posts: 30
Joined: Wed Feb 01, 2012 5:18 pm

Next

Return to General Help

Who is online

Users browsing this forum: No registered users and 1 guest