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

Linker error 2038 msvc 2015 debug build #4231

Closed
friente opened this issue Apr 5, 2018 · 34 comments
Closed

Linker error 2038 msvc 2015 debug build #4231

friente opened this issue Apr 5, 2018 · 34 comments
Labels

Comments

@friente
Copy link

friente commented Apr 5, 2018

Hello everyone,

I'm going to use shogun on windows. I'm having a problem installing it with vcpkg. But I have already opened an issue for that.
In the meanwhile, I'm trying to use CMAKE to generate the MSVC 2015 Win64 solution and generate the debug and release build.
The release build works fine. I have tried it with the minimal usage examples here reported.
Unfortunately, I'm getting LNK2038 error when using the debug build of the library in debug mode.

Here I report the CMAKE log:

The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: E:/Software/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working C compiler: E:/Software/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: E:/Software/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working CXX compiler: E:/Software/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Could NOT find CCache (missing: CCACHE CCACHE_VERSION) 
Using system's malloc
Could NOT find GDB (missing: GDB_COMMAND GDB_VERSION) 
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) (Required is at least version "1.8.6")
dir='C:/Users/myUser/Downloads/shogun-shogun_6.1.3/shogun-shogun_6.1.3/src'
dir='C:/Users/myUser/Downloads/shogun-shogun_6.1.3/shogun-shogun_6.1.3/build/src'
Could NOT find CxaDemangle (missing: HAVE_CXA_DEMANGLE) 
Could NOT find CxaDemangle (missing: HAVE_CXA_DEMANGLE) 
Could NOT find Eigen3 (missing: EIGEN_INCLUDE_DIR) (Required is at least version "3.1.2")
Could NOT find OPENCL (missing: OPENCL_LIBRARY OPENCL_INCLUDE_DIR) 
Could NOT find ViennaCL (missing: VIENNACL_INCLUDE_DIR VIENNACL_ENCODED_VERSION OpenCL_INCLUDE_DIRS OpenCL_LIBRARIES) (Required is at least version "1.5.0")
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
Could NOT find TFLogger (missing: TFLogger_DIR)
A library with BLAS API not found. Please specify library location.
LAPACK requires BLAS
Could NOT find GLPK (missing: GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND) 
Could NOT find CPLEX (missing: CPLEX_LIBRARY CPLEX_INCLUDE_DIR) 
Could NOT find MOSEK (missing: MOSEK_DIR MOSEK_INCLUDE_DIR MOSEK_LIBRARY MOSEK_LIBRARIES) 
Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR) 
Could NOT find JSON (missing: JSON_INCLUDE_DIR JSON_LIBRARY) (Required is at least version "0.11")
Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR) 
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) 
Could NOT find LibLZMA (missing: LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET) 
Lzo includes and libraries NOT found. 
Could NOT find NLOPT (missing: NLOPT_LIBRARY NLOPT_INCLUDE_DIR) 
Could NOT find LPSOLVE (missing: LPSOLVE_LIBRARIES LPSOLVE_INCLUDE_DIR) 
Could NOT find ColPack (missing: COLPACK_LIBRARIES COLPACK_LIBRARY_DIR COLPACK_INCLUDE_DIR) 
Could NOT find ARPREC (missing: ARPREC_LIBRARIES ARPREC_INCLUDE_DIR) 
Linker: Default system linker
Ctags flavour: Exuberant
Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE) 
Failed to locate pandoc executable (missing: PANDOC_EXECUTABLE) 
===================================================================================================================
Summary of Configuration Variables
The following OPTIONAL packages have been found:

 * OpenMP
 * Threads
 * SNAPPY
 * Ctags

-- The following REQUIRED packages have been found:

 * PythonInterp

-- The following OPTIONAL packages have not been found:

 * CCache
 * GDB
 * Doxygen (required version >= 1.8.6)
 * CxaDemangle
 * Eigen3 (required version >= 3.1.2)
 * ViennaCL (required version >= 1.5.0)
 * rxcpp
 * TFLogger (required version >= 0.1.0)
 * BLAS
 * GLPK
 * CPLEX
 * ARPACK
 * Mosek
 * Protobuf
 * JSON (required version >= 0.11)
 * LibXml2
 * CURL
 * ZLIB
 * BZip2
 * LibLZMA
 * LZO
 * NLopt
 * LpSolve
 * ColPack
 * ARPREC
 * Sphinx
 * Pandoc

===================================================================================================================
Integrations
  OpenCV Integration is OFF 	 enable with -DOpenCV=ON
===================================================================================================================
Interfaces
  Python is OFF 		 enable with -DINTERFACE_PYTHON=ON
  Octave is OFF 		 enable with -DINTERFACE_OCTAVE=ON
  Java is OFF 		 enable with -DINTERFACE_JAVA=ON
  Perl is OFF 		 enable with -DINTERFACE_PERL=ON
  Ruby is OFF 		 enable with -DINTERFACE_RUBY=ON
  C# is OFF 			 enable with -DINTERFACE_CSHARP=ON
  R is OFF 			 enable with -DINTERFACE_R=ON
  Lua is OFF 		 enable with -DINTERFACE_LUA=ON
  Scala is OFF 		 enable with -DINTERFACE_SCALA=ON
===================================================================================================================
To compile shogun type
  make

To install shogun to C:/Users/myUser/Desktop/shogun type
  make install

or to install to a custom directory
  make install DESTDIR=/my/special/path
  (or rerun cmake with -DCMAKE_INSTALL_PREFIX=/my/special/path) to just change the prefix
===================================================================================================================
Configuring done
Generating done

The generated errors are:


C:\Users\myUser\Desktop\shoguntest\libs\shogun\include\shogun/lib/any.h(391): note: see reference to function template instantiation 'bool shogun::Any::same_type<shogun::Any::Empty>(void) const' being compiled
	link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:..\build_debug\shoguntest.exe @C:\Users\myUser\AppData\Local\Temp\shoguntest.exe.128816.1437.jom
shogun.lib(memory.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(memory.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(SGIO.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(SGIO.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(SGObject.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(SGObject.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(SGMatrix.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(SGMatrix.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(GaussianKernel.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(GaussianKernel.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(DenseLabels.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(DenseLabels.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(BinaryLabels.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(BinaryLabels.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(LibSVM.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(LibSVM.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(init.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(init.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(DenseFeatures.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(DenseFeatures.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(ShogunException.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(ShogunException.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
shogun.lib(SGReferencedData.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
shogun.lib(SGReferencedData.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 
etc...
etc...
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
..\build_debug\shoguntest.exe : fatal error LNK1319: 1114 mismatches detected
jom: C:\Users\myUser\Desktop\shoguntest\src\Makefile.Debug [..\build_debug\shoguntest.exe] Error 1319
jom: C:\Users\myUser\Desktop\shoguntest\src\Makefile [debug] Error 2
18:56:36: The process "E:\Software\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project shoguntest (kit: Desktop Qt 5.9.3 MSVC2015 64bit)
When executing step "Make"
18:56:36: Elapsed time: 00:03.

I have also tried building the library in "RelWithDebInfo" but the final ouput is equal when used.
What is wrong with my debug build of the library?

@friente friente changed the title Linker error 2038 Linker error 2038 msvc 2015 debug build Apr 5, 2018
@friente
Copy link
Author

friente commented Apr 9, 2018

I know that is a problem with the run time libraries. I'm built shogun with debug flag in MSVC 2015, but it seems that it was instead build in release. Isn't it?
It is possible to generate a debug .dll of the shogun lib?
I read in many places that shogun can be use just with static linking. Is it true?

@vigsterkr
Copy link
Member

vigsterkr commented Apr 9, 2018

@fyoda i'm not so sure how do you end up here.... could you maaaybe reproduce the commands of appveyor or what's in the manual for windows, namely:

cmake -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug -DBUILD_META_EXAMPLES=OFF -DENABLE_TESTING=ON ..

msbuild "C:\projects\shogun\build\shogun.sln" /verbosity:minimal /t:Clean /p:Configuration=Debug /p:Platform=x64

@friente
Copy link
Author

friente commented Apr 9, 2018

The cmake command you reported cannot work as is. When, executed from command line you get the error about the GPL and SVM flag. Only the following command works for me:

cmake -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug -DBUILD_META_EXAMPLES=OFF -DENABLE_TESTING=ON -DLICENSE_GPL_SHOGUN=OFF -DUSE_SVMLIGHT=OFF ..

@vigsterkr
Copy link
Member

@fyoda what? :) i mean if you do not want GPL sure thing that you can disable it... but that work as it works on appveyor. you are missing the submodules:

git submodule update --init

@friente
Copy link
Author

friente commented Apr 9, 2018

I'm sorry, I forgot the submodules. Now your CMAKE command works fine.
I built the solution with MSVC in Debug configuration.

msbuild "C:\projects\shogun\build\shogun.sln" /verbosity:minimal /t:Clean /p:Configuration=Debug /p:Platform=x64

It builds without errors. However, I'm getting errors LNK2038 when I'm using the .dll generated on the with the sample code posted here.
It seems that the .dll is built against Release RT library instead of the debug.

@vigsterkr
Copy link
Member

vigsterkr commented Apr 9, 2018

@fyoda i'm not so sure that DLL should be linkable to a simple example - like the minimal code. for that you should compile with the static lib... if you want to use the dll you need to load it into memory with LoadLibrary; but correct me if i'm wrong. it's not the same as in case of *NIX systems shared libraries....

@friente
Copy link
Author

friente commented Apr 9, 2018

@vigsterkr I'm just trying to run the following code, first in Debug mode, than in Release:

#include <shogun/labels/Labels.h>
#include <shogun/features/DenseFeatures.h>
#include <shogun/kernel/GaussianKernel.h>
#include <shogun/classifier/svm/LibSVM.h>
#include <shogun/base/init.h>
#include <shogun/lib/common.h>
#include <shogun/io/SGIO.h>

#pragma comment(lib, "winmm")  // added to avoid error LNK2019 posted here (https://stackoverflow.com/questions/49613254/linker-error-2019-using-shogun-dll-on-windows?noredirect=1#comment86344894_49613254)

using namespace shogun;

int main(int argc, const wchar_t *argv[])
{
    init_shogun_with_defaults();

    // create some data
    SGMatrix<float64_t> matrix(2,3);
    for (int32_t i=0; i<6; i++)
        matrix.matrix[i]=i;

    // create three 2-dimensional vectors
    // shogun will now own the matrix created
    CDenseFeatures<float64_t>* features= new CDenseFeatures<float64_t>();
    features->set_feature_matrix(matrix);

    // create three labels
    CBinaryLabels* labels=new CBinaryLabels(3);
    labels->set_label(0, -1);
    labels->set_label(1, +1);
    labels->set_label(2, -1);

    // create gaussian kernel with cache 10MB, width 0.5
    CGaussianKernel* kernel = new CGaussianKernel(10, 0.5);
    kernel->init(features, features);

    // create libsvm with C=10 and train
    CLibSVM* svm = new CLibSVM(10, kernel, labels);
    svm->train();

    // classify on training examples
    for (int32_t i=0; i<3; i++)
        SG_SPRINT("output[%d]=%f\n", i, svm->apply_one(i));

    // free up memory
    SG_UNREF(svm);

    exit_shogun();
    return 0;
}

At the end of the debug I have four files:

  • shogun.dll
  • shogun.ilk
  • shogun.lib
  • shogun.pdb

at the end of the release just two:

  • shogun.dll
  • shogun.lib

Now I took both shared libraries I tried to build the example code posted above, first in Debug mode (with debug lib), then Release (with release lib).

At the first build, I got the following error in the include file include\shogun/io/SGIO.h

fatal error C1083: Cannot open include file: 'dirent.h': No such file or directory

Modifying direct.h with io.h to solve this issue.

In Debug I get the following errors:

main.obj : error LNK2019: unresolved external symbol "void __cdecl shogun::init_shogun_with_defaults(void)" (?init_shogun_with_defaults@shogun@@YAXXZ) referenced in function main
main.obj : error LNK2019: unresolved external symbol "void __cdecl shogun::exit_shogun(void)" (?exit_shogun@shogun@@YAXXZ) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: void __cdecl shogun::SGIO::message(enum shogun::EMessageType,char const *,char const *,int,char const *,...)const " (?message@SGIO@shogun@@QEBAXW4EMessageType@2@PEBD1H1ZZ) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: int __cdecl shogun::CSGObject::unref(void)" (?unref@CSGObject@shogun@@QEAAHXZ) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: __cdecl shogun::SGMatrix<double>::SGMatrix<double>(int,int,bool)" (??0?$SGMatrix@N@shogun@@QEAA@HH_N@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: __cdecl shogun::SGMatrix<double>::SGMatrix<double>(class shogun::SGMatrix<double> const &)" (??0?$SGMatrix@N@shogun@@QEAA@AEBV01@@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl shogun::SGMatrix<double>::~SGMatrix<double>(void)" (??1?$SGMatrix@N@shogun@@UEAA@XZ) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: __cdecl shogun::CGaussianKernel::CGaussianKernel(int,double)" (??0CGaussianKernel@shogun@@QEAA@HN@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: bool __cdecl shogun::CDenseLabels::set_label(int,double)" (?set_label@CDenseLabels@shogun@@QEAA_NHN@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: __cdecl shogun::CBinaryLabels::CBinaryLabels(int)" (??0CBinaryLabels@shogun@@QEAA@H@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: __cdecl shogun::CLibSVM::CLibSVM(double,class shogun::CKernel *,class shogun::CLabels *,enum shogun::LIBSVM_SOLVER_TYPE)" (??0CLibSVM@shogun@@QEAA@NPEAVCKernel@1@PEAVCLabels@1@W4LIBSVM_SOLVER_TYPE@1@@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: __cdecl shogun::CDenseFeatures<double>::CDenseFeatures<double>(int)" (??0?$CDenseFeatures@N@shogun@@QEAA@H@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: void __cdecl shogun::CDenseFeatures<double>::set_feature_matrix(class shogun::SGMatrix<double>)" (?set_feature_matrix@?$CDenseFeatures@N@shogun@@QEAAXV?$SGMatrix@N@2@@Z) referenced in function main
main.obj : error LNK2001: unresolved external symbol "class shogun::SGIO * shogun::sg_io" (?sg_io@shogun@@3PEAVSGIO@1@EA)
..\build_debug\shoguntest.exe : fatal error LNK1120: 14 unresolved externals
jom: C:\Users\myUser\Desktop\shoguntest\src\Makefile.Debug [..\build_debug\shoguntest.exe] Error 1120
jom: C:\Users\myUser\Desktop\shoguntest\src\Makefile [debug] Error 2

In Release, linking against release shogun lib the example compile and works fine.

@vigsterkr
Copy link
Member

@fyoda modifying direct.h? you mean dirent.h? none the less you have to actually use the right include flags for shogun (check exported target) before you wanna compile against the lib.... otherwise of course you are going have troubles compiling your code.

on the other hand i'd actually link with the static lib, which i dont get why wouldn't has any of those symbols in case of a Debug mode.... that's only adds debug information to the obj not removing functions. are you sure that you are having the right linker flags to find the debug mode library?

@friente
Copy link
Author

friente commented Apr 9, 2018

@vigsterkr I meant dirent.h, sorry for the typo.

I don't understand. What do you mean with proper flag? I would try to link shogun statically to the example, but at the end of the build process I don't see any shogun.a file.

@vigsterkr
Copy link
Member

there's no such thing as shogun.a in windows... it's shogun.lib

@friente
Copy link
Author

friente commented Apr 9, 2018

@vigsterkr I'm sorry, I got confused. Even if I use static linking against the example I get the same LNK2019 errors reported above, both in release and debug mode:

@vigsterkr
Copy link
Member

@fyoda but the libshogun (c++ examples) compiles fine?

@friente
Copy link
Author

friente commented Apr 9, 2018

@vigsterkr If compiles fine, but I get an error in the unit test configuration of Eigen library 3.3.4 and it is not able to find BLAS:

  -- Could NOT find BLAS (missing: BLAS_SEQ_LIBRARIES BLAS_LIBRARY_DIRS)
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_36e9f"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_deb92"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_bf5a6"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_72b43"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_9d63b"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_596b4"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_fb51e"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_aaeda"
  -- Could NOT find MPI_C (missing: MPI_C_WORKS)
  -- Could NOT find MPI_CXX (missing: MPI_CXX_COMPILER)
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_d81d4"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_3c064"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_4a82d"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_33bb4"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_cb92d"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_803de"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_87edd"
CUSTOMBUILD : CMake error : Generator: execution of make failed. Make command was: "devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_58dca"
  -- Could NOT find MPI_Fortran (missing: MPI_Fortran_COMPILE)

@vigsterkr
Copy link
Member

vigsterkr commented Apr 9, 2018

can you run the tests? meaning ctest? because those errors are just warning you that no BLAS/LAPACK is found, but that should still work - eigen does not require to have lapack/blas, it's optional..

@friente
Copy link
Author

friente commented Apr 9, 2018

@vigsterkr In which solution can I find ctest?

@vigsterkr
Copy link
Member

mmm it's not a solution.. .it's part of cmake.... as you have ran cmake with -DENABLE_TESTING=ON that will enable tests including unit tests and some other c++ examples.

@vigsterkr
Copy link
Member

please read this before further questions:
https://github.com/shogun-toolbox/shogun/blob/develop/doc/readme/DEVELOPING.md

@friente
Copy link
Author

friente commented Apr 9, 2018

@vigsterkr I did and read all the developing information. Indeed, in the INTERFACES.md I see normal information on how to use shogun as Shared Library. I'm not interested in interfaces with other scripting languages, but just with C++. They are simple instruction on how to use link a shared lib.

In EXAMPLES.md I just see information on how to run automatically generated example. Unfortunately, they are available only with BUILD_META_EXAMPLE flag enabled. Thus, no meta examples are available since the CMAKE command you suggested has -DBUILD_META_EXAMPLES=OFF flag.

The only tests I'm able to run now are the unit tests, which passed.
I don't see any other file in the build/examples, maybe I'm looking in the wrong folder.

@vigsterkr
Copy link
Member

@fyoda if unit tests are passing that it definitely managed to link with shogun.lib.
BUILD_EXAMPLES cmake flag is by default turned on that means all the libshogun examples ought to be compiled&linked as well, i.e. if you run ctest -R libshogun you should have some test that pass.

@friente
Copy link
Author

friente commented Apr 10, 2018

@vigsterkr Ok the test runs correctly. I have tried linking statically the library to the example and it works only with Release library.
In the debug I get the same error. I think there is some problem with the generation of the MSVC solution in debug mode. It could be possible? Could you try to generate debug .lib and link them statically to the example? I think it is related to this post.

@friente
Copy link
Author

friente commented Apr 10, 2018

@vigsterkr in my opinion, the problem happens when in MSVC the user switches from Debug to Release configuration. Indeed the Runtime Library is not updated properly. It should be:
For shared library in Release: Multi-threaded DLL should be set automatically
For shared library in Debug: Multi-threaded Debug DLL should be set

Instead, in the shogun solution... Even if I select the Debug configuration, the Multi-threaded DLL is set in all submodules, that is wrong: --> look here

@friente
Copy link
Author

friente commented Apr 10, 2018

@vigsterkr I just changed manually the Runtime Lib in all submodules and worked out. So, there is a problem with the generation of the MSVC solution using CMAKE. It works with dynamic and static linking.

@vigsterkr
Copy link
Member

vigsterkr commented Apr 10, 2018

@fyoda submodules? i'm not so sure if i follow... moreover, if the libshogun examples are successfully compiled and linked then it means that your custom linking/compilation is broken...
meaning if you compile it with:

cmake -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug -DBUILD_META_EXAMPLES=OFF -DENABLE_TESTING=ON ..

msbuild "C:\projects\shogun\build\shogun.sln" /verbosity:minimal /t:Clean /p:Configuration=Debug /p:Platform=x64

or

cmake -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DBUILD_META_EXAMPLES=OFF -DENABLE_TESTING=ON ..

msbuild "C:\projects\shogun\build\shogun.sln" /verbosity:minimal /t:Clean /p:Configuration=Release /p:Platform=x64

if you are referring to the fact that when you run once in the cmake say with -DCMAKE_BUILD_TYPE=Release and then switch in your MSVC application the type to Debug (or vice versa) then i think this is not fully supported by cmake generated solution, but i might be wrong. anyhow this is strictly cmake related issue, nothing to do with shogun. in case the above mentioned commands separately work fine (meaning that you run cmake in a clean build directory)

@friente
Copy link
Author

friente commented Apr 10, 2018

@vigsterkr I meant subprojects within the generated MSVC solution.
Summarizing, the shogun library as is, works only in Release mode. Because if you try to run:

cmake -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug -DBUILD_META_EXAMPLES=OFF -DENABLE_TESTING=ON ..

msbuild "C:\projects\shogun\build\shogun.sln" /verbosity:minimal /t:Clean /p:Configuration=Debug /p:Platform=x64

And you link the generated library against an example in debug configuration you experience the Runtime library errors I posted above.

This is fully supported by CMAKE to switch between debug and release build within MSVC.
As an example, if you try to generate the solution of the labstreaminglayer project, you will see that you can switch back and forth the MSVC configuration without problem.

In addition to that, to get you C++ working it is mandatory to add:

#pragma comment(lib, "winmm") // added to avoid error LNK2019 posted here (https://stackoverflow.com/questions/49613254/linker-error-2019-using-shogun-dll-on-windows?noredirect=1#comment86344894_49613254)

and change the include file shogun/io/SGIO.h from dirent.h to io.h, because dirent.h cannot be found.

@vigsterkr
Copy link
Member

mmmm i have to check with dirent.h but io.h won't work... it needs maaaybe some fixing.... lemme make an issue about that.

i'm not so sure if i understand why would this happen - Debug not working in case of MSVC & shogun. i'm using cmake to generate the solution files, so i dont understand what's missing or how. ideas?

@vigsterkr
Copy link
Member

@fyoda have you maybe checked whether adding

#pragma comment(lib, "winmm")

to https://github.com/shogun-toolbox/shogun/blob/develop/src/shogun/lib/Time.cpp#L92

@friente
Copy link
Author

friente commented Apr 10, 2018

@vigsterkr I didn't try. I just added

#pragma comment(lib, "winmm")

to my main.cpp example to solve the issue. I can try to add it to Time.cpp and I'll let you know.

@vigsterkr
Copy link
Member

if you could add & test that'd be really great thnx!

@friente
Copy link
Author

friente commented Apr 11, 2018

@vigsterkr Adding
#pragma comment(lib, "winmm")

in Time.cpp, rebuilding the library solved the issue when building the c++ example.

@stale
Copy link

stale bot commented Feb 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 26, 2020
@gf712
Copy link
Member

gf712 commented Feb 26, 2020

@vigsterkr still relevant? Should be addressed in the windows fixes?

@stale stale bot removed the stale label Feb 26, 2020
@vigsterkr
Copy link
Member

this should be autoclosed once #4719 is merged. i've marked there this issue

@stale
Copy link

stale bot commented Aug 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Aug 31, 2020

This issue is now being closed due to a lack of activity. Feel free to reopen it.

@stale stale bot closed this as completed Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants