[Solved] Include Directory Conflicts?

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 MVP, CEGUI Team

Ido
Just popping in
Just popping in
Posts: 5
Joined: Wed Jun 21, 2017 08:55

[Solved] Include Directory Conflicts?

Postby Ido » Wed Jun 21, 2017 09:12

I believe I have correctly created CEGUI with Cmake. However, when go to integrate it into my own Cmake project (within Visual Studio 2017) I encounter problems. The moment I add the line

include_directories(Z:/CEGUI/cegui-0.8.7/cegui/include/CEGUI)

I get 1286 errors from standard C++ libs like istream, string, algorithm etc that look all over the place. CEGUI header files seem so unconnected to the C++ libs so I can't understand why it causes them to go haywire. Any help or suggestions are greatly appreciated. Here is my entire CMakeLists.txt file. Sorry about the mess. I tried adding CEGUI the same way as SFML but I kept running into a bunch of issues:

Code: Select all

cmake_minimum_required(VERSION 3.0)

project(citystates)

# Set options
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
set(SFML_STATIC_LIBS FALSE CACHE BOOL "Choose whether SFML is linked statically or shared.")
set(CITYBUILDER_STATIC_STD_LIBS FALSE CACHE BOOL "Use statically linked standard/runtime libraries? This option must match the one used for SFML.")
set(SFML_ROOT "Z:/SFML2.4.1/SFML-2.4.1/;${SFML_ROOT}")

# Make sure that the runtime library gets link statically
if(CITYBUILDER_STATIC_STD_LIBS)
   if(NOT SFML_STATIC_LIBS)
      message("\n-> If you check CITYBUILDER_STATIC_STD_LIBS, you also need to check SFML_STATIC_LIBRARIES.")
      message("-> It would lead to multiple runtime environments which result in undefined behavior.\n")
   elseif(WIN32 AND MSVC)
      # Change all MSVC compiler flags to /MT
      foreach(flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE)
         if(${flag} MATCHES "/MD")
         string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
         endif()
      endforeach()
   elseif(CMAKE_COMPILER_IS_GNUCXX)
      # Note: Doesn't work for TDM compiler, since it's compiling the runtime libs statically by default
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
   endif()
endif()

# citybuilder uses C++11 features
if(CMAKE_COMPILER_IS_GNUCXX)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

# Add directory containing FindSFML.cmake to module path
set(CMAKE_MODULE_PATH "Z:/SFML2.4.1/SFML-2.4.1/cmake/Modules/;${CMAKE_MODULE_PATH}")

# Make sure that FindSFML.cmake searches for the static libraries
if(SFML_STATIC_LIBS)
   set(SFML_STATIC_LIBRARIES TRUE)
endif()

# Find SFML
find_package(SFML COMPONENTS graphics window system)

# Output an error if SFML wasn't found
if(SFML_FOUND)
   include_directories(${SFML_INCLUDE_DIR})
else()
   set(SFML_ROOT "" CACHE PATH "SFML top-level directory")
   message("\n-> SFML directory not found. Set SFML_ROOT to SFML's top-level path (containing \"include\" and \"lib\" directories).")
   message("-> Make sure the SFML libraries with the same configuration (Release/Debug, Static/Dynamic) exist.\n")
endif()

include_directories(Z:/CEGUI/cegui-0.8.7/build/cegui/include/CEGUI)
include_directories(Z:/CEGUI/cegui-0.8.7/cegui/include/CEGUI)

# Add the source files
file(GLOB CITYBUILDER_SRC
   "*.h"
   "*.cpp"
)

# Tell CMake to build a executable
add_executable(citystates ${CITYBUILDER_SRC})

# Link SFML
target_link_libraries(citystates ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})

# Link CEGUI
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/CEGUIOpenGLRenderer-0_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/CEGUIBase-0_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/freetype_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/glew_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/glfw_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/jpeg_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/libexpat_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/libpng_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/pcre_d.lib )
target_link_libraries(citystates optimized Z:/CityStates/CityStates/CEGUI/SILLY_d.lib )

#target_link_libraries(citystates ${CEGUI_LIBRARIES} )


# Install executable
install(TARGETS citystates
      RUNTIME DESTINATION .)

# Install game assets
install(DIRECTORY media/
      DESTINATION media/)
      
# Install config files
install(FILES city_cfg.dat city_map.dat LICENSE README.md
      DESTINATION .)


Just a note that I can add include_directories(Z:/CEGUI/cegui-0.8.7/build/cegui/include/CEGUI) and everything still builds just fine.

iceiceice
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Thu Jul 09, 2015 10:20

Re: Include Directory Conflicts?

Postby iceiceice » Wed Jun 21, 2017 16:37

Hi,

Maybe post the first error message in full? And code at line no it refers to?

Often if theres tons of errors in a standard library header it can be because it is accidentally included from within one of your namespaces. U might want to check if you are including cegui headers from in your namespace accidentally. Just a guess.

I cant really speak to your cmake, it looks alright to me. I have no experience with visual studio. Normally, adding an include directory doesnt actually pull in any code unless there are also #include directives in your other files that refer to the new stuff. So its wierd that just adding that line to cmake will break things as you say. Is it trying to do precompiled headers or something?

Cheers,
Iceiceice

Ido
Just popping in
Just popping in
Posts: 5
Joined: Wed Jun 21, 2017 08:55

Re: Include Directory Conflicts?

Postby Ido » Wed Jun 21, 2017 19:11

Thanks for the reply iceiceice! At the moment I have everything in the global namespace. However, I double checked all my code and I don't include a CEGUI library anywhere (I did in one file a couple times for testing purposes a while back but it's commented out). I can't imagine VS would be precompiling any headers; from what I can see the whole build process is done through cmake. Anyway here is the first error:

Error C2039 'strlen': is not a member of '`global namespace'' File: iosfwd

Code: Select all

static size_t __CLRCALL_OR_CDECL length(_In_z_ const _Elem * const _First) _NOEXCEPT // strengthened
      {   // find length of null-terminated string
      return (_CSTD strlen(_First));
      }

From what I can see every part of cstring used in iosfwd is unrecognized.

User avatar
Ident
CEGUI Team
Posts: 1822
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Include Directory Conflicts?

Postby Ident » Wed Jun 21, 2017 19:16

Not sure if related but what gives you the idea that this

Code: Select all

include_directories(Z:/CEGUI/cegui-0.8.7/cegui/include/CEGUI)

would be correct (no offense, just honestly curious)?


Have you tried

Code: Select all

include_directories(Z:/CEGUI/cegui-0.8.7/cegui/include)
?
CrazyEddie: "I don't like GUIs"

Ido
Just popping in
Just popping in
Posts: 5
Joined: Wed Jun 21, 2017 08:55

Re: Include Directory Conflicts?

Postby Ido » Thu Jun 22, 2017 03:53

Oh god, I'm an idiot.. Looking at the folder names it seems so painfully obvious now. At the time my thought process was something like, "Well here I am looking at all the header files I want. Lemme just copy pasta this directory, what could go wrong?".

My eternal thanks Ident! Time to dive into CEGUI proper. Here's to hoping you won't see me in the help section again.

User avatar
Ident
CEGUI Team
Posts: 1822
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Include Directory Conflicts?

Postby Ident » Thu Jun 22, 2017 07:28

Ido wrote:My eternal thanks Ident! Time to dive into CEGUI proper. Here's to hoping you won't see me in the help section again.

Well it would be still good to see you again here, even if it is just to let us know you are still using CEGUI :D

If CEGUI were to become so bug-free and self-explanatory that people won't come to the forums anymore, we might at some point believe no one is using us anymore :hammer: ( Maybe we should wilfully add some bugs that are not fending off people at the start, but later make them have to come to the forum to seek help, it would serve as usage metric )
CrazyEddie: "I don't like GUIs"

iceiceice
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Thu Jul 09, 2015 10:20

Re: [Solved] Include Directory Conflicts?

Postby iceiceice » Sun Jun 25, 2017 00:26

Can't believe i missed that, going to return my tech support badge now. :roll:

Glad you figured it out.


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest