Skip to content

Unable to create DLL under VS15 2017 using CMake generated .sln #20

@rgcv

Description

@rgcv

I've managed to generate a Visual Studio solution through cmake via cmake -G "Visual Studio 15 2017 Win64, which worked apparently seamlessly. My objective was to produce a dll out of the hello world example in the readme, i.e., Boost's hello world.

However, once I try to build the project, linking errors start to pop up, along with some warnings mentioning some declarations "need(s) to have a dll-interface to be used by" some class.

Here's my CMakeLists.txt

cmake_minimum_required(VERSION 2.8.12)
project(HelloWorld)

find_package(JlCxx REQUIRED)

add_library(hello_world SHARED src/hello_world.cpp)
target_link_libraries(hello_world JlCxx::cxxwrap_julia ${Julia_LIBRARY})

install(TARGETS
  hello_world
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION lib)

Build output in VS15 2017

1>------ Build started: Project: ZERO_CHECK, Configuration: Release x64 ------
2>------ Build started: Project: hello_world, Configuration: Release x64 ------
2>hello_world.cpp
2>c:\user\home\appdata\local\julia-1.0.2\include\julia\julia.h(871): warning C4146: unary minus operator applied to unsigned type, result still unsigned
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(567): warning C4251: 'jlcxx::Module::m_pointer_array': class 'jlcxx::ArrayRef<void *,1>' needs to have dll-interface to be used by clients of class 'jlcxx::Module'
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(567): note: see declaration of 'jlcxx::ArrayRef<void *,1>'
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(568): warning C4251: 'jlcxx::Module::m_functions': class 'std::vector<std::shared_ptr<jlcxx::FunctionWrapperBase>,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of class 'jlcxx::Module'
2>        with
2>        [
2>            _Ty=std::shared_ptr<jlcxx::FunctionWrapperBase>
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(568): note: see declaration of 'std::vector<std::shared_ptr<jlcxx::FunctionWrapperBase>,std::allocator<_Ty>>'
2>        with
2>        [
2>            _Ty=std::shared_ptr<jlcxx::FunctionWrapperBase>
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(569): warning C4251: 'jlcxx::Module::m_jl_constants': class 'std::map<std::string,jl_value_t *,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>' needs to have dll-interface to be used by clients of class 'jlcxx::Module'
2>        with
2>        [
2>            _Kty=std::string,
2>            _Ty=jl_value_t *
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(569): note: see declaration of 'std::map<std::string,jl_value_t *,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>'
2>        with
2>        [
2>            _Kty=std::string,
2>            _Ty=jl_value_t *
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(570): warning C4251: 'jlcxx::Module::m_reference_types': class 'std::vector<jl_datatype_t *,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of class 'jlcxx::Module'
2>        with
2>        [
2>            _Ty=jl_datatype_t *
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(85): note: see declaration of 'std::vector<jl_datatype_t *,std::allocator<_Ty>>'
2>        with
2>        [
2>            _Ty=jl_datatype_t *
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(571): warning C4251: 'jlcxx::Module::m_allocated_types': class 'std::vector<jl_datatype_t *,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of class 'jlcxx::Module'
2>        with
2>        [
2>            _Ty=jl_datatype_t *
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(85): note: see declaration of 'std::vector<jl_datatype_t *,std::allocator<_Ty>>'
2>        with
2>        [
2>            _Ty=jl_datatype_t *
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(1085): warning C4251: 'jlcxx::ModuleRegistry::m_modules': class 'std::map<jl_module_t *,std::shared_ptr<jlcxx::Module>,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>' needs to have dll-interface to be used by clients of class 'jlcxx::ModuleRegistry'
2>        with
2>        [
2>            _Kty=jl_module_t *,
2>            _Ty=std::shared_ptr<jlcxx::Module>
2>        ]
2>c:\user\home\.julia\packages\cxxwrap\kcmsi\deps\usr\include\jlcxx\module.hpp(1085): note: see declaration of 'std::map<jl_module_t *,std::shared_ptr<jlcxx::Module>,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>'
2>        with
2>        [
2>            _Kty=jl_module_t *,
2>            _Ty=std::shared_ptr<jlcxx::Module>
2>        ]
2>   Creating library Z:/Path/To/Proj/Release/hello_world.lib and object Z:/Path/To/Proj/Release/hello_world.exp
2>hello_world.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl jlcxx::FunctionWrapperBase::~FunctionWrapperBase(void)" (__imp_??1FunctionWrapperBase@jlcxx@@UEAA@XZ) referenced in function "public: virtual void * __cdecl jlcxx::FunctionPtrWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::`scalar deleting destructor'(unsigned int)" (??_G?$FunctionPtrWrapper@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@$$V@jlcxx@@UEAAPEAXI@Z)
2>hello_world.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl jlcxx::FunctionWrapperBase::set_name(struct _jl_value_t *)" (__imp_?set_name@FunctionWrapperBase@jlcxx@@QEAAXPEAU_jl_value_t@@@Z) referenced in function define_julia_module
2>hello_world.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl jlcxx::FunctionWrapperBase::set_pointer_indices(void)" (__imp_?set_pointer_indices@FunctionWrapperBase@jlcxx@@IEAAXXZ) referenced in function define_julia_module
2>hello_world.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl jlcxx::Module::append_function(class jlcxx::FunctionWrapperBase *)" (__imp_?append_function@Module@jlcxx@@QEAAXPEAVFunctionWrapperBase@2@@Z) referenced in function define_julia_module
2>C:\User\Home\source\repos\hello_world\Release\hello_world.dll : fatal error LNK1120: 4 unresolved externals
2>Done building project "hello_world.vcxproj" -- FAILED.
3>------ Build started: Project: ALL_BUILD, Configuration: Release x64 ------
4>------ Skipped Build: Project: INSTALL, Configuration: Release x64 ------
4>Project not selected to build for this solution configuration 
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

I'm not really sure what to do, I'm new to building DLLs, meaning I know nearly nothing about it. I've tried setting up a solution manually as well with no success found there. Hoping I'm just doing something silly and this actually has a dead obvious solution.

Also, my end goal, which might seem obvious, would be to have a codebase for the wrapper and be able to generate both shared objects and DLLs. Ultimately, if I could eventually get there, create a single shared library that would be generated and used upon package installation/compilation, for example. But that's another issue altogether.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions