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

When I compile on the window system use cmake 3.26, there are many redefinition errors, please help #111

Closed
sorise opened this issue Jun 5, 2024 · 4 comments

Comments

@sorise
Copy link

sorise commented Jun 5, 2024

F:\WorkShop\git-repo\muse-simulator\build\bin\Debug\bls384.dll : fatal error LNK1169: one or more multiply defined symbols found [F:\WorkShop\git-repo\muse-simulator\build\dependency\bls\bls384.vcxproj]
mclbn384_256.vcxproj -> F:\WorkShop\git-repo\muse-simulator\build\bin\Debug\mclbn384_256.dll
Building Custom Rule F:/WorkShop/git-repo/muse-simulator/dependency/bls/CMakeLists.txt
mcl.lib(fp.obj) : error LNK2005: "unsigned __int64 __cdecl mcl::bint::addUnit(unsigned __int64 *,unsigned __int64,unsigned __int64)" (?addUnit@bint@mcl@@YA_KPEA_K_K1@Z) already defined in mclbn384_256.lib(mclbn384_256.dll) [F:\WorkShop\git-repo\muse-simulato
r\build\dependency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "unsigned __int64 __cdecl mcl::bint::div(unsigned __int64 *,unsigned __int64,unsigned __int64 *,unsigned __int64,unsigned __int64 const *,unsigned __int64)" (?div@bint@mcl@@YA_KPEA_K_K01PEB_K1@Z) already defined in mclbn384_256
.lib(mclbn384_256.dll) [F:\WorkShop\git-repo\muse-simulator\build\dependency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "unsigned __int64 __cdecl mcl::bint::divUnit(unsigned __int64 *,unsigned __int64 const *,unsigned __int64,unsigned __int64)" (?divUnit@bint@mcl@@YA_KPEA_KPEB_K_K2@Z) already defined in mclbn384_256.lib(mclbn384_256.dll) [F:
\WorkShop\git-repo\muse-simulator\build\dependency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "void __cdecl mcl::bint::initBint(void)" (?initBint@bint@mcl@@yaxxz) already defined in mclbn384_256.lib(mclbn384_256.dll) [F:\WorkShop\git-repo\muse-simulator\build\dependency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "void __cdecl mcl::bint::maskN(unsigned __int64 *,unsigned __int64,unsigned __int64)" (?maskN@bint@mcl@@YAXPEA_K_K1@Z) already defined in mclbn384_256.lib(mclbn384_256.dll) [F:\WorkShop\git-repo\muse-simulator\build\dependency\de
pendency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "unsigned __int64 __cdecl mcl::bint::modUnit(unsigned __int64 const *,unsigned __int64,unsigned __int64)" (?modUnit@bint@mcl@@YA_KPEB_K_K1@Z) already defined in mclbn384_256.lib(mclbn384_256.dll) [F:\WorkShop\git-repo\muse-simula
tor\build\dependency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "void __cdecl mcl::bint::mulNM(unsigned __int64 *,unsigned __int64 const *,unsigned __int64,unsigned __int64 const *,unsigned __int64)" (?mulNM@bint@mcl@@YAXPEA_KPEB_K_K12@Z) already defined in mclbn384_256.lib(mclbn384_256.dll
) [F:\WorkShop\git-repo\muse-simulator\build\dependency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "unsigned __int64 __cdecl mcl::bint::shiftLeft(unsigned __int64 *,unsigned __int64 const *,unsigned __int64,unsigned __int64)" (?shiftLeft@bint@mcl@@YA_KPEA_KPEB_K_K2@Z) already defined in mclbn384_256.lib(mclbn384_256.dll) [F:
\WorkShop\git-repo\muse-simulator\build\dependency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "unsigned __int64 __cdecl mcl::bint::shiftRight(unsigned __int64 *,unsigned __int64 const *,unsigned __int64,unsigned __int64)" (?shiftRight@bint@mcl@@YA_KPEA_KPEB_K_K2@Z) already defined in mclbn384_256.lib(mclbn384_256.dll)
[F:\WorkShop\git-repo\muse-simulator\build\dependency\bls\bls384_256.vcxproj]
mcl.lib(fp.obj) : error LNK2005: "unsigned __int64 __cdecl mcl::bint::subUnit(unsigned __int64 *,unsigned __int64,unsigned __int64)" (?subUnit@bint@mcl@@YA_KPEA_K_K1@Z) already defined in mclbn384_256.lib(mclbn384_256.dll) [F:\WorkShop\git-repo\muse-simulator\b
uild\dependency\bls\bls384_256.vcxproj]

@herumi
Copy link
Owner

herumi commented Jun 6, 2024

Could you show me what command did you enter?
I haven't maintenance CMakeLists.txt for Windows properly, so I want you to open the x64 Native Tools Command Prompt in Visual Studio and create a dll with mklib dll or mklib dll eth.
If you need a static library, use mklib or mklib eth.
I'll check CMakeLits.txt later.

@herumi
Copy link
Owner

herumi commented Jun 8, 2024

I could not modify CMakeLists.txt for Windows, so please use a vcxproj file. See https://github.com/herumi/bls/tree/dev .

@sorise
Copy link
Author

sorise commented Jun 9, 2024

I have solved this problem, just modify the CMakeList. txt file in the bls directory。(Modify as shown below)
and then i can use cmake 3.26 with visual stduio 2022 build successfully !
and then build test in linux ubuntu 22.04 gcc11.4 cmake 3.26 successfully !

You can consider the following modifications to CMakeList, which should have a minor impact. (CMakeLists.txt Line 58 #)

foreach(bit IN ITEMS 256 384 384_256)
	add_library(bls${bit} SHARED src/bls_c${bit}.cpp)
	add_library(bls::bls${bit} ALIAS bls${bit})
	target_compile_definitions(bls${bit} PRIVATE BLS_NO_AUTOLINK)
	target_include_directories(bls${bit} PUBLIC
		$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
		$<INSTALL_INTERFACE:${CMAKE_INSTALL_DIR}/include>)
        # Modify HERE START
	target_link_libraries(bls${bit} PUBLIC mcl::mcl mcl::mcl_st mcl::mclbn${bit})
	# Modify HERE END
         set_target_properties(bls${bit} PROPERTIES
	  POSITION_INDEPENDENT_CODE ON
	  VERSION ${bls_VERSION}
	  SONAME ${bls_VERSION_MAJOR})
endforeach()

Thank you for your response.

@herumi
Copy link
Owner

herumi commented Jun 9, 2024

Thank you for the nice patch. I've merged it.

@sorise sorise closed this as completed Jun 10, 2024
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