Building LIBSVM on WIndows - libsvm

I am trying to do a build from the command line for a windows PC of the version of LIBSVM 3.17 modified to allow weighted instances
(from http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/#weights_for_data_instances ).
I am using the executable tools from Microsoft Visual Studio 2010, but am getting an error I don't understand. Microsoft's documentation of the error gets me no further. Can anyone point me in a useful direction, or has anyone managed to compile this package for Windows?
I am running at the command line:
nmake -f Makefile.win
and getting an error:
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0 \VC\bin\cl.exe"' : return code '0xc0000135' Stop.
The full makefile is:
**CXX = cl.exe
CFLAGS = -nologo -O2 -EHsc -I. -D __WIN32__ -D _CRT_SECURE_NO_DEPRECATE
TARGET = windows
all: $(TARGET)\svm-train.exe $(TARGET)\svm-predict.exe $(TARGET)\svm-scale.exe $(TARGET)\svm-toy.exe lib
$(TARGET)\svm-predict.exe: svm.h svm-predict.c svm.obj
$(CXX) $(CFLAGS) svm-predict.c svm.obj -Fe$(TARGET)\svm-predict.exe
$(TARGET)\svm-train.exe: svm.h svm-train.c svm.obj
$(CXX) $(CFLAGS) svm-train.c svm.obj -Fe$(TARGET)\svm-train.exe
$(TARGET)\svm-scale.exe: svm.h svm-scale.c
$(CXX) $(CFLAGS) svm-scale.c -Fe$(TARGET)\svm-scale.exe
$(TARGET)\svm-toy.exe: svm.h svm.obj svm-toy\windows\svm-toy.cpp
$(CXX) $(CFLAGS) svm-toy\windows\svm-toy.cpp svm.obj user32.lib gdi32.lib comdlg32.lib -Fe$(TARGET)\svm-toy.exe
svm.obj: svm.cpp svm.h
$(CXX) $(CFLAGS) -c svm.cpp
lib: svm.cpp svm.h svm.def
$(CXX) $(CFLAGS) -LD svm.cpp -Fe$(TARGET)\libsvm -link -DEF:svm.def
clean:
-erase /Q *.obj $(TARGET)\**

I would suggest you to compile it from visual studio directly since is easier, but if you still want to do it from the command like this link might help:
NMAKE : fatal error U1077: return code '0xc0000135'
Apparently the problem is that NMake couldn't find the compiler's path.

I discovered (by guessing) that I needed to manually create a directory called "windows" where the executables were produced. Not entirely sure why this was necessary, but it did the job, and I still can't see a way to do it without doing so.

Related

Building ParaView-Superbuild in windows 10

I'm trying to build the ParaView-Superbuild (https://gitlab.kitware.com/paraview/paraview-superbuild) on Windows 10 64x.
I cannot manage to get it to work. I just ran from error to error. Currently I'm stuck at:
CMake Error at superbuild/projects/win32/boost.cmake:5 (message):
At least Visual Studio 9.0 is required
Call Stack (most recent call first):
superbuild/cmake/SuperbuildMacros.cmake:690 (include)
superbuild/CMakeLists.txt:145 (_superbuild_discover_projects)
using Cmake 3.13.10-rc1 as generator for Ninja. I have Cygwin64 installed and I'm using the GCC compiler
The C compiler identification is GNU 7.3.0
The CXX compiler identification is GNU 7.3.0
Since I thought that the error has something to do with the compiler I tried to switch to the installed VS2017 compiler. However, the build process will then crash with
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules
/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools
/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/paraview-superbuild/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/Ninja/ninja.exe" "cmTC_915a7"
[1/2] Building C object CMakeFiles\cmTC_915a7.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_915a7.exe
FAILED: cmTC_915a7.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe
--intdir=CMakeFiles\cmTC_915a7.dir --manifests -- C:\PROGRA~2\MICROS~1
\2017\ENTERP~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo
CMakeFiles\cmTC_915a7.dir\testCCompiler.c.obj /out:cmTC_915a7.exe
/implib:cmTC_915a7.lib /pdb:cmTC_915a7.pdb /version:0.0 /machine:x64
/debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib
advapi32.lib && cd ."
RC Pass 1: command "rc /foCMakeFiles\cmTC_915a7.dir/manifest.res
CMakeFiles\cmTC_915a7.dir/manifest.rc" failed (exit code 0) with the
following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (
I don't know how to fix the error using the GCC compiler when the VS one is not working at all. Sadly, I couldn't find any help on the Paraview website.
Has somebody managed to build it and can show me step by step how to do it?
And no, I don't want to use Linux here.
Thanks.
Here is a reliable way to build ParaView Superbuild on windows
Install Visual Studio 2013 community with all C++ related tools
Install cmake
Install git bash
Install Ninja
Install Qt 5.9.2 VS2013
Install other potential dependencies
open git bash
then :
cd C:/
mkdir pv
cd pv
git clone git#gitlab.kitware.com:paraview/paraview-superbuild.git
mv paraview-superbuild pvsb
mkdir pvsb_b
cd pvsb
git submodule update --init --recursive
Open Visual Studio Native Command X64
then :
cd C:\pv\pvsb_b
cmake-gui
configure paraview-superbuild accordingly to your need
ENABLE_qt5 and USE_SYSTEM_qt should be ON
generate
close cmake-gui
ninja

Fortran file dependency with Intel ifort

I am working in a standard Unix environment, with Intel Fortran 2012 compiler.
since my codes have some old .f files and some newer .f90 files, the makefile is organized in the following structure,
f_sources= ... ...
f90_sources= ... ...
f_objects = $(patsubst %.f,%.o,$(f_sources))
f90_objects = $(patsubst %.f90,%.o,$(f90_sources))
$(f_objects): %.o: %.f
#echo compiling $<
$(FC) $(FC_FLAGS) -c $< -o $#
# compile f90 files:
$(f90_objects): %.o: %.f90
#echo compiling $<
$(FC) $(FC_FLAGS) -c $< -o $#
The problem is, few strange .f files depend on the modules defined in some .f90 files, and then the compiler seems not able to detect the dependency since I compile first all the .f files...
Error in opening the compiled module file. Check INCLUDE paths.
Is there a way to solve this problem?
Add
f77_file_with_module_dependency.o: f90_file_for_module.o
to your Makefile somewhere.
Supposing that you have a there.f file that depends on mod_here.f90, you declare in your makefile the following:
there.o: mod_here.o
$(FC) $(FC_FLAG) -c there.f -o there.o
When the makefile gets to this file, there.f, it will see that it depends on mod_here.f90, which hasn't yet been compiled, so it'll compile it.

nmake Makefile cl.exe include folder

I have a project written in and I'm trying to compile it using nmake Makefile. The project setup is as follow:
MyProject\
Makefile
src\
includes\
header1.h
header2.h
module1\
module1.h
module1.c
module2\
module2.h
module2.c
some.h
some.c
module1.c includes header1.h and header2.h.
module2.c includes header2.h
Now in my Makefile I'm trying to compile module1 first and then module2.
CC = cl.exe
CFLAGS = /link /DLL
build:
$(CC) src\module1\module1.c $(CFLAGS)
$(CC) src\module2\module2.c $(CFLAGS)
Now I'm getting error of Cannot open include file: includes\header1.h. After some research in this website, everyone suggested to use /I DIR flag. So in my Makefile I added:
CFLAGS = /link /DLL /I src\includes
But I'm still getting the same error. Can someone please help me on how to fix this issue?
Thanks

g++: error: unrecognized option ‘--end-group’

I had been using ubuntu 10.10 for quite some time as my development PC. My code was to build without error with g++ version 4.4.5. Recently I had upgraded my system to 11.10 which has come with g++ version 4.6.1
Now , using this compiler, when I am trying to build the same piece of code, I am getting this error:
g++: error: unrecognized option ‘--end-group’
The Make file line, where this error is thrown is:
$(TARGET): $(OBJS)
g++ $(LDFLAGS) $^ $ -Wl,--start-group $(ARCHIVE_LIBS) --end-group -o $(TARGET)
cp -f $(TARGET) ../../../bin/
Can some please throw some light on this? I had googled but I did not get any clue?
Thanks and Regards,
Souvik
--end-group is a linker flag so you should prefix it with -Wl, i.e.
g++ $(LDFLAGS) $^ $ -Wl,--start-group $(ARCHIVE_LIBS) -Wl,--end-group -o $(TARGET)
I am not sure why this worked before.

Compile C++ code to run on ESXi 3.5

I'm trying to compile a simple c++ program to run inside ESXi 3.5 console window. It seems I'm linking with wrong libraries... Is there a setup described somewhere - which version of G++ and libraries do I have to be using in order to do so?
Here's how I resolved the issue. I did following to compile:
Compiled using gcc under ubuntu
Ran ldd on executable
Copied all libraries that showed up as dependencies to subfolder ESXi-3.5-lib. In my case they were:
ld-linux.so.2
libc.so.6
libgcc_s.so.1
libm.so.6
libstdc++.so.5
Added following switches to gcc:
-nodefaultlibs (to not attempt to link with default libs)
-lc (prevented link error in some crt library)
-fno-stack-protector (prevented another error, some other function was missing)
Following was my final build command:
g++ file1.cpp file2.cpp file3.cpp -o output-biinary-file-name \
ESXi-3.5-lib/ld-linux.so.2 ESXi-3.5-lib/libc.so.6 ESXi-3.5-lib/libgcc_s.so.1\
ESXi-3.5-lib/libm.so.6 ESXi-3.5-lib/libstdc++.so.5 \
-nodefaultlibs -lc -m32 -fno-stack-protector