Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresolved external symbols on MSVC #435

Closed
gardc opened this issue Mar 17, 2021 · 3 comments
Closed

Unresolved external symbols on MSVC #435

gardc opened this issue Mar 17, 2021 · 3 comments

Comments

@gardc
Copy link

gardc commented Mar 17, 2021

I am trying to get my compiled libtins working on Windows without any luck.
I've followed the download and installing guide. Compiles libtins from build/libtins.sln without any problems, though it only gives a x64 solution platform whereas I'm going to use it for building a 32bit executable. I'm not sure whether that matters.

When including libtins in my test code, I am getting these errors:

main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Tins::PDU::~PDU(void)" (??1PDU@Tins@@UAE@XZ) referenced in function "public: virtual __thiscall Tins::EthernetII::~EthernetII(void)" (??1EthernetII@Tins@@UAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Tins::EthernetII::EthernetII(class Tins::HWAddress<6> const &,class Tins::HWAddress<6> const &)" (??0EthernetII@Tins@@QAE@ABV?$HWAddress@$05@1@0@Z) referenced in function _main
1>...\libtins\build\lib\Release\tins.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
1>...\Debug\libtins_test.exe : fatal error LNK1120: 2 unresolved externals

main.cpp test code:

#define WIN32_LEAN_AND_MEAN
#define TINS_STATIC
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS

#include <tins/tins.h>
#include <iostream>

using namespace Tins;
using std::endl;

const int main() {
	EthernetII eth;

	std::cout << "Hello" << endl;

	return 0;
}
@laudrup
Copy link
Contributor

laudrup commented Mar 17, 2021

I've followed the download and installing guide. Compiles libtins from build/libtins.sln without any problems, though it only gives a x64 solution platform whereas I'm going to use it for building a 32bit executable. I'm not sure whether that matters.

That does indeed matter and is the reason for the error you see. I don't use Visual Studio myself so I cannot guide you, but try to see if you can change the solution to build a 32-bit library somehow. That should fix your issue.

@gardc
Copy link
Author

gardc commented Mar 18, 2021

That does indeed matter and is the reason for the error you see. I don't use Visual Studio myself so I cannot guide you, but try to see if you can change the solution to build a 32-bit library somehow. That should fix your issue.

I used either -CMAKE_GENERATOR_PLATFORM=Win32 or -A=Win32, and that generated a Visual Studio solution with Win32 as build target. But then I got an LNK1112 error specifically on address_range.obj when trying to build.

@gardc
Copy link
Author

gardc commented Mar 18, 2021

I got it to build now using cmake ../ -DPCAP_ROOT_DIR=<dir> -DLIBTINS_ENABLE_WPA2=0 -DLIBTINS_BUILD_SHARED=0 -G "Visual Studio 16 2019" -A Win32 to generate the project.
Should this perhaps be noted in the documentation for CMake noobs such as myself?

And as a note for others who might have problems; only the release version of libtins.lib works with release build of the lib consumer and debug lib for debug build 🤯

@gardc gardc closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants