Reputation:
I have created Qt class library with Qt VS Tools for visual studio 2019. I included this library to my Qt project that I too made with Qt VS tools, but now my project won't build.
That is .pro file of my project:
# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Tools.
# ------------------------------------------------------
TEMPLATE = app
TARGET = JanturiolGameServer
DESTDIR = ./Win32/Debug
QT += core network gui widgets networkauth
CONFIG += debug
DEFINES += _UNICODE _ENABLE_EXTENDED_ALIGNED_STORAGE WIN64 QT_DLL QT_NETWORK_LIB QT_NETWORKAUTH_LIB QT_WIDGETS_LIB
INCLUDEPATH += ../../JanturiolLib \
./GeneratedFiles \
. \
./GeneratedFiles/$(ConfigurationName)
LIBS += -L"../../JanturiolLib"
DEPENDPATH += .
MOC_DIR += ./GeneratedFiles/$(ConfigurationName)
OBJECTS_DIR += debug
UI_DIR += ./GeneratedFiles
RCC_DIR += ./GeneratedFiles
include(JanturiolGameServer.pri)
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../JanturiolLib/Win32/release/ -lJanturiolLib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../JanturiolLib/Win32/debug/ -lJanturiolLib
else:unix: LIBS += -L$$PWD/../JanturiolLib/Win32/ -lJanturiolLib
INCLUDEPATH += $$PWD/../JanturiolLib
DEPENDPATH += $$PWD/../JanturiolLib
That is .pro file of my library:
# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Tools.
# ------------------------------------------------------
TEMPLATE = lib
TARGET = JanturiolLib
DESTDIR = ./Win32/Release
QT += core xml network gui uitools widgets networkauth
CONFIG += release
DEFINES += _UNICODE _ENABLE_EXTENDED_ALIGNED_STORAGE WIN64 QT_DLL QT_NETWORK_LIB QT_NETWORKAUTH_LIB QT_UITOOLS_LIB QT_WIDGETS_LIB QT_XML_LIB JANTURIOLLIB_LIB
INCLUDEPATH += ./GeneratedFiles \
. \
./GeneratedFiles/$(ConfigurationName)
DEPENDPATH += .
MOC_DIR += ./GeneratedFiles/$(ConfigurationName)
OBJECTS_DIR += release
UI_DIR += ./GeneratedFiles
RCC_DIR += ./GeneratedFiles
include(JanturiolLib.pri)
That is PlayerChracter.h:
#pragma once
#include "BaseCharacter.h"
#include <string>
enum CharacterClass{warrior, mage, ranger};
//position
struct Pos
{
int xPos;
int yPos;
};
class PlayerCharacter : public BaseCharacter
{
public:
PlayerCharacter(std::string charName);
virtual ~PlayerCharacter();
protected:
std::string name;
Pos position;
};
That is PlayerChracter.cpp:
#include "PlayerCharacter.h"
PlayerCharacter::PlayerCharacter(std::string charName)
{
name = charName;
position.xPos = 0;
position.yPos = 0;
}
PlayerCharacter::~PlayerCharacter()
{
}
If I try to build project by the visual studio, I get this error:
1>------ Build started: Project: JanturiolGameServer, Configuration: Debug Win32 ------ 1>JanturiolGameServer.cpp 1>JanturiolGameServer.obj : error LNK2019: unresolved external symbol "public: __thiscall PlayerCharacter::PlayerCharacter(class std::basic_string,class std::allocator >)" (??0PlayerCharacter@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "private: void __thiscall JanturiolGameServer::ProcessDatagram(class QByteArray &)" (?ProcessDatagram@JanturiolGameServer@@AAEXAAVQByteArray@@@Z) 1>C:\Users\GKR\source\repos\JanturiolGameServer\Win32\Debug\JanturiolGameServer.exe : fatal error LNK1120: 1 unresolved externals 1>Done building project "JanturiolGameServer.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If I try to build project by the Qt creator 4. 9. 0, I get this error:
https://monosnap.com/file/f9XQ1s0VQpfx8e6PXYtkaNl2X409ra
That is path to .lib file:
https://monosnap.com/file/oeaH3vuXMIYQ7aLY3vcWd6qk0QqOOy
Upvotes: 0
Views: 725
Reputation: 441
In your project file you have set WIN64 but your compiler output states Debug Win32.
See "You attempt to link 64-bit libraries to 32-bit code, or 32-bit libraries to 64-bit code" as possible cause at https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2019?view=vs-2019
Upvotes: 0