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

Include header files and .lib files generated with VS 2022: MSVC fail to link #215

Open
InTimeTechnologies opened this issue May 8, 2024 · 2 comments

Comments

@InTimeTechnologies
Copy link

InTimeTechnologies commented May 8, 2024

Bug Report

Current behavior:
I built used CMake to generate the Visual Studio project successfully.
I built the Visual Studio solution and all 7 builds in the solution were successful and created Debug and Release versions of the .lib files.
I included the .lib files generated in my project and the include folder provided in the source code but failed to link any of the functions with the libraries. Here are the error messages:

Build started at 4:44 AM...
1>------ Build started: Project: LibraryTest, Configuration: Debug x64 ------
1>main.cpp
1>C:\Users\chris\source\repos\LibraryTest\LibraryTest\vendor\dogecoin\libdogecoin.h(464,9): warning C4068: unknown pragma 'GCC'
1>(compiling source file 'main.cpp')
1>C:\Users\chris\source\repos\LibraryTest\LibraryTest\vendor\dogecoin\libdogecoin.h(465,9): warning C4068: unknown pragma 'GCC'
1>(compiling source file 'main.cpp')
1>C:\Users\chris\source\repos\LibraryTest\LibraryTest\vendor\dogecoin\libdogecoin.h(467,9): warning C4068: unknown pragma 'GCC'
1>(compiling source file 'main.cpp')
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl dogecoin_ecc_start(void)" (?dogecoin_ecc_start@@YAXXZ) referenced in function main
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl dogecoin_ecc_stop(void)" (?dogecoin_ecc_stop@@YAXXZ) referenced in function main
1>C:\Users\chris\source\repos\LibraryTest\x64\Debug\LibraryTest.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "LibraryTest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 4:44 AM and took 01.050 seconds ==========

Please help. I've been trying to have libdogecoin work around a year now but end up coming back to check if it is stable enough to work on MSVC. This is the closest I've ever gotten it to work. I am trying to accept Dogecoin in my own projects and keep hitting a roadblock. I've compiled other libraries before for game development and never had an issue I couldn't figure out on my own.

Expected behavior
I expect to link the .lib files in my Visual Studio project and include the dogecoin/libdogecoin.h header file at the very list and be able to not get any linking errors.

Steps to reproduce:
I wrote the simplest of codes to test the compilation:

// Dependencies | std
#include <iostream>

// Dependencies | dogecoin
#include <dogecoin/libdogecoin.h>

int main(int argc, char* argv[]) {
	std::cout << "Program operating" << std::endl;

	dogecoin_ecc_start();
	dogecoin_ecc_stop();

	std::cout << "Program operating" << std::endl;
}

I used CMake to build the VS solution, opened and built the VS solution, copied the dogecoin.lib file into my test project, and finally linked the .lib files and the include folder into my project. 

Screenshots
imageimage

libdogecoin commit

Machine specs

  • OS: Windows 11 Pro
  • CPU: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz 3.60 GHz
  • RAM: 64.0 GB (63.9 GB usable)
  • Disk size: 1 Tb x 2
  • Disk Type (HD/SDD): 2 SSDs installed in the mother board

Extra information
Here is the output that was printed when the VS solution was created:
Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
CMake Deprecation Warning at CMakeLists.txt:22 (cmake_minimum_required):

Compatibility with CMake < 3.5 will be removed from a future version of
CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.

fatal: not a git repository (or any of the parent directories): .git

--

-- ---( Libevent 2.1.12-stable )---

-- Available event backends:
-- CMAKE_BINARY_DIR: C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/build
-- CMAKE_CURRENT_BINARY_DIR: C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/build
-- CMAKE_SOURCE_DIR: C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent
-- CMAKE_CURRENT_SOURCE_DIR: C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent
-- PROJECT_BINARY_DIR: C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/build
-- PROJECT_SOURCE_DIR: C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent
-- CMAKE_MODULE_PATH: C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/cmake/
-- CMAKE_COMMAND: C:/Program Files/CMake/bin/cmake.exe
-- CMAKE_ROOT: C:/Program Files/CMake/share/cmake-3.27
-- CMAKE_SYSTEM: Windows-10.0.22631
-- CMAKE_SYSTEM_NAME: Windows
-- CMAKE_SYSTEM_VERSION: 10.0.22631
-- CMAKE_SYSTEM_PROCESSOR: AMD64
-- CMAKE_SKIP_RPA
TH: NO
-- CMAKE_VERBOSE_MAKEFILE: FALSE
-- CMAKE_C_FLAGS: /DWIN32 /D_WINDOWS /W3
-- CMAKE_BUILD_TYPE: Release
-- CMAKE_C_COMPILER: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe (id MSVC, clang 0, GNUC 0)
-- CMAKE_AR: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/lib.exe
-- CMAKE_RANLIB: :

-- Configuring done (0.1s)

-- Generating done (0.1s)

-- Build files have been written to: C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/build

MSBuild version 17.9.8+b34f75857 for .NET Framework

1>Checking Build System

Building Custom Rule C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/CMakeLists.txt

event_core_static.vcxproj -> C:\Users\chris\Desktop\libdogecoin-0.1.3-dev\src\libevent\build\lib\Release\event_core.lib

Building Custom Rule C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/CMakeLists.txt

event_extra_static.vcxproj -> C:\Users\chris\Desktop\libdogecoin-0.1.3-dev\src\libevent\build\lib\Release\event_extra.lib

Building Custom Rule C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/CMakeLists.txt

event_static.vcxproj -> C:\Users\chris\Desktop\libdogecoin-0.1.3-dev\src\libevent\build\lib\Release\event.lib

Building Custom Rule C:/Users/chris/Desktop/libdogecoin-0.1.3-dev/src/libevent/CMakeLists.txt

Options used to compile and link:
USE_TESTS = 1
WITH_TOOLS = ON
WITH_NET = ON
WITH_LOGDB = ON
WITH_UNISTRING = ON
WITH_WALLET = ON

USE_SSE2 = OFF
USE_TPM2 = ON
TEST_PASSWD = OFF

openenclave = OFF

library type = Static

Configuring done (1.3s)
Generating done (0.1s)

@InTimeTechnologies InTimeTechnologies changed the title Include header files and .lib files generated with VS 2022 fail to link Include header files and .lib files generated with VS 2022: MSVC fail to link May 8, 2024
@edtubbs
Copy link
Collaborator

edtubbs commented May 8, 2024

Hello! Wrap your libdogecoin.h include with extern "C" since it's a C standard library. You can find some examples of C++ usage in the address.md: libdogecoin/address.md.

@edtubbs
Copy link
Collaborator

edtubbs commented May 21, 2024

Were you able to resolve your issue @InTimeTechnologies? Thanks!

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