LNK2019错误,几乎尝试一切,没有任何作用

时间:2015-04-04 09:46:57

标签: c++ visual-studio-2013 cmake linker-errors sfml

对不起我的英语,不是我的主要语言,希望大家都能理解。 在第一行代码发布五年后,我第一次尝试制作游戏。由于我想创建一些有组织且易于阅读的东西,我决定使用CMake创建一个Visual Studio项目,该项目包含用于我未来代码的不同部分的各种库,并将每个库与我需要的SFML链接。

不幸的是,我并不擅长CMake。所以,我应该花一点时间花更多时间去挖一个。我已经克服了一些困难,但是现在,我非常封锁。我尝试的一切都没有解决我的问题,所以它真的很烦人。

好吧,现在问题出在哪里!我创建的每个库都应该链接到SFML库。除此之外,他们显然没有。我编译我的解决方案时遇到的错误(他们是法语,但我认为你会得到这个想法):

  • core_data.lib(GameLoop.obj):错误LNK2001:symbole externenonrésolu“public:virtual __thiscall sf :: Window :: ~Window(void)”(?? 1Window @sf @@ UAE @ XZ )

  • core_data.lib(GameLoop.obj):错误LNK2019:symbole externenonrésolu“public:__ thishisall sf :: String :: String(class std :: basic_string,class std :: allocator> const& ,类std :: locale const&)“(?? 0String @ sf @@ QAE @ ABV?$ basic_string @ DU?

  • $ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ ABVlocale @ 3 @@ Z)référencédansla fonction“private:void __thiscall GameLoop :: initMainWindow(void) “(?initMainWindow @ GameLoop @@ AAEXXZ)

  • core_data.lib(GameLoop.obj):错误LNK2019:symbole externenonrésolu“public:__ thiscall sf :: VideoMode :: VideoMode(unsigned int,unsigned int,unsigned int)”(?? 0VideoMode @sf @@ QAE @ III @ Z)référencédansla fonction“private:void __thiscall GameLoop :: initMainWindow(void)”(?initMainWindow @ GameLoop @@ AAEXXZ)

  • core_data.lib(GameLoop.obj):错误LNK2019:symbole externenonrésolu“public:__ thiscall sf :: Window :: Window(void)”(?? 0Window @sf @@ QAE @ XZ)référencé dans la fonction“public:__thiscall GameLoop :: GameLoop(class std :: basic_string,class std :: allocator>,unsigned int,unsigned int)”(?? 0GameLoop @@ QAE @ V?$ basic_string @ DU?$ char_traits @ d @ @@ STD V'$分配器@ d @ @@ 2 STD @@ @ II Z)

  • core_data.lib(GameLoop.obj):错误LNK2019:symbole externenonrésolu“public:void __thiscall sf :: Window :: create(class sf :: VideoMode,class sf :: String const&amp ;,, unsigned int,struct sf :: ContextSettings const&)“(?create @ Window @ sf @@ QAEXVVideoMode @ 2 @ ABVString @ 2 @ IABUContextSettings @ 2 @@ Z)référencédansla fonction”private:void __thiscall GameLoop :: initMainWindow (无效)“(?initMainWindow @ GameLoop @@ AAEXXZ)

  • core_data.lib(GameLoop.obj):错误LNK2019:symbole externenonrésolu“public:bool __thiscall sf :: Window :: isOpen(void)const”(?isOpen @ Window @sf @@ QBE_NXZ) référencédansla fonction“public:int __thiscall GameLoop :: run(void)”(?run @ GameLoop @@ QAEHXZ)

  • C:\ Users \ Fleurus \ Desktop \ build \ sfmlBase \ bin \ Debug \ sfmlBase.exe:致命错误LNK1120:6 externesnonrésolus

每次调用SFML函数都会导致链接错误。如果我没错,那就是.lib的标志,不包括在内。除了它们似乎被我在CMakeLists.txt中所做的包括在内。下面是为每个使用SFML创建的库调用的宏:

MACRO(Library_Configuration)

# We get the name of the current builded library with the name of the current directory
get_filename_component(LIB_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 
# We set the complete name of the library
set(COMPLETE_LIBRARY_NAME  ${MOD_NAME}_${LIB_NAME})
# We define the path of the headers files
set(HEADER_FILES_PATH ../../../include/${MOD_NAME})
# Inclusion of headers files
file(GLOB HEADER_FILES ${HEADER_FILES_PATH}/${LIB_NAME}/*.h)
# If there is header files
if(EXISTS ${HEADER_FILES})
    set(LIBRARY_BUILT ON)
    # We take every source files of the current directory 
    file(GLOB SOURCES_FILES *.cpp)      
    # We build the library with headers and sources previously research
    add_library(${COMPLETE_LIBRARY_NAME} ${HEADER_FILES} ${SOURCES_FILES})
    # That's where seems to be the problem
    target_include_directories(${COMPLETE_LIBRARY_NAME} PUBLIC ${HEADER_FILES_PATH} ${SFML_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/export) 
    target_link_libraries(${COMPLETE_LIBRARY_NAME} ${SFML_LIBRARIES})
    set_property(TARGET ${COMPLETE_LIBRARY_NAME} PROPERTY FOLDER ${MOD_NAME})

    # Fichier d'export... 
    generate_export_header(${COMPLETE_LIBRARY_NAME} EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/export/${COMPLETE_LIBRARY_NAME}_export.h)
    set (LIBRARY_BUILT_LIST )
    set (LIBRARY_BUILT_LIST ${LIBRARY_BUILT_LIST} ${COMPLETE_LIBRARY_NAME} CACHE INTERNAL "LIBRARY_BUILT_LIST")

else()
    set(LIBRARY_BUILT OFF) 
endif()
ENDMACRO()

为了更好地理解,这是我的工作目录的架构:

  • app(我的程序的入口点在哪里)
  • 包括(应该是显而易见的)
      • 物理
      • audio
      • 数据
      • 对照
      • 图形
    • 游戏
      • 物理
      • audio
      • 数据
      • 对照
      • 图形
  • SRC
      • 物理
      • audio
      • 数据
      • 对照
      • 图形
    • 游戏
      • 物理
      • audio
      • 数据
      • 对照
      • 图形
  • CMakeLists.txt(主要的)

就是这样。希望我很清楚,你可以帮助我。谢谢!

编辑:感谢您将标记重复,但该主题并没有真正帮助。我知道什么是LNK2019错误,我不知道如何解决这个错误在我的Cmakelist宏中添加一些内容......

0 个答案:

没有答案