Building GSL (GNU Scientific Library) in Windows for use with VS2015 - c++

I am trying to build GSL as a library(DLL,lib) to use with my application. I have tested both GSL ports(gladman) to VS and CMake route and I do not want to go that path due to various reasons.
Currently I am using nuget version and I am not too happy about it as some functions are missing. I want to build it myself to be absolutely sure about what I am getting. The objective is to build four set of dll and libs---win32, win32d, win64 and win64d.
I know that from a MinGW library I can build lib file(for VS2015) and thereafter dll using Microsoft LIB tool if I have DEF file available.
My open source experience is very limited. Till now I have successfully built gsl for MinGW using ./config, make, make install. But I am not finding any DEF file generated and I do not know how to utilize this build to generate required DEF and dll to be used with Microsoft Visual Studio 2015.
Thank you

Building and linking has always been a pain for me as well. For mac, I use Homebrew, which downloads frameworks and libraries through a simple one-line-command in the terminal. I would then simply add the library into my program by adding the directory of the libs necessary. In XCode, there was an "add framework/library"-button where I added the directories, but I'm sure there's an analogue in VS.
However, you seem to be using Windows (so Homebrew will not work). I searched the web for Windows versions of Homebrew, and it seems that Scoop is pretty similar. You might want to check that out.
Hope this helped, despite me using different tools :)

Related

Converting a Linux Library Project into a Library Project usable in windows

I am attempting to convert the ndn library project found at "https://github.com/named-data/ndn-cpp" into something that can be imported into several existing mfc/wpf/forms Visual Studio Projects (building it as .lib or .dll would work).
As a note, it appears to have previously been converted into c# for windows for a older build of ndn, but is no long supported and will not connect with the current ndn network.(https://github.com/named-data/ndn-dot-net)
I have looked into the using the WSL features that they have added to windows 10, and the Visual studio Linux Cross Platform projects, but these all seem to only be able to make .exes that will run in windows not a .lib or .dll that can be imported into another project.
I have also look into the shared items project but what I was able to find didn't seem like it would work for what I'm trying to do.
Lastly, I tried using cygwin. I was able to compile and generate the linux style libraries(.a) on my windows 10 machine, but when i attempted to generate windows style dlls off the .o files(gcc -shared -o mydll.dll mydll.o) I ran into a large number of reference errors that I was unable to resolve.
Does anyone have any recommendations on which of these methods I should be using or if I should be attempting some other method entirely?
Does anyone have any good references or examples of how to do this for someone with limited Linux experience?
Thanks
Ok. I've tried going about this several ways now, and here's what I've learned that might be useful to someone else trying to do this and also where I stand so far:
If you have a simple Linux dll that you have written it's possible to compile it as a Windows dll using MSYS2 or MINGW, instructions are here: http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs
If you have something a bit more complicated like the program I'm trying to convert above, there is no quick fix to convert from Linux to windows, however you still might be able to compile your program for windows using Visual Studio.
Here's how you do it:
Download vcpkg from https://github.com/microsoft/vcpkg This is a linux package manager for windows, it will allow you to download windows equivalents to many common Linux packages (for the above I had to download boost and sqlite3)
Create your own unistd.h, here's a link to that: Is there a replacement for unistd.h for Windows (Visual C)?
Get dirent.h for windows, here's a link to that: https://github.com/tronkko/dirent
replace instances of gmtime with _mkgmtime or redefine gmtime as _mkgmtime: timegm cross platform
This got me about 90% of the way there (and from about 13,000 compiler errors to about 30), The rest of the errors so far have been for calls where there is no easy linux to windows conversion and those sections of code have had to be re-written. (In the code above this would be the socket code for the tcp/udp connections in the tranport files, Linux and Windows handle it pretty differently, boost does have a good guide for how to use it's sockets in windows though: https://www.boost.org/doc/libs/1_60_0/more/getting_started/windows.html)
So that's it. Hopefully this helps someone else down the line. I'll be adding more to this answer as I discover new things.

Building log4cplus for Windows x64

I am supposed to build existing Windows 32bit project for Windows 64bit. (and probably linux 64bit too).
The project uses log4cplus library. That one only contains 32bit .lib files at the moment and is shining example of why I hate using libraries in C++ - there's just a bunch of source files and linux bash scripts. The INSTALL help file is entirely about the configure bash script which doesn't work on Windows. The configure probably just passes some arguments to GCC, but I don't known which ones.
I downloaded MinGW in hope I'll be able to use mingw32-make on the project and it will work, but no such thing happened.
So does anyone have any experience making those Linux projects on Windows? This is not the first time I tackle this problem - my third most viewed question is about broken Boost build. Judging from the view count, I'm not the only one who has problems building Linux project on widnows.
log4cplus maintainer here.
The master branch of log4cplug GIT repository is C++11 only. Because of this, it requires Visual Studio 2015 and thus the msvc14 directory is there.
Branch 1.2.x and its releases come with Visual Studio project files for version 2010. However, you might be able to build it using CMake for even older Visual Studio.
However, both of them, in any configuration, should have no problem building for AMD64 platform.
I also suggest that you read the README.md file. It documents many things, some of which might be useful to you, too.

Importing a GNU/Linux C++ package into Visual Studio on Windows

I have no experience with Linux, so this question might seem weird.
I am trying to use a c++ toolbox which has been developed on Debian GNU/Linux Lenny. According to the authors it should work on any recent Linux distribution. However, I need to import it into Visual Studio on Windows.
I have no idea how to get this package configured and built on Visual Studio. I see that there is a "configure" file in the package, but I don't how to use it on Windows. Any help would be appreciated.
You can use either MinGW or Cygwin to mock a *nix system enough to build most *nix software. The configure script is generally a (*nix) shell script which will check to see what interfaces and libraries are available to the application during compilation.
Depending on the library you may not be able to use it outside of a unix library, especially if the library depends on the POSIX (*nix) APIs beyond the very small set which Windows provides.
From your information the package is meant for linux.
This means that if the package contains precompiled code (such as .so or .a - shared libraries / static libraries)you will not be able to run it under windows no matter what (make abstraction of Linux simulated enviroments, I believe you want to run it on a Windows environment).
If the package contains only sources, then you can include the package inside your solution (I would personally go with a static library approach) and try to compile it. You will get some errors when linux specific headers are included (for example linux threading headers).
After finding the windows equivalent for those functions you will be able to compile and use the package on windows as well.
You basically have to do a manual port.

SDL 2.0 with Code::Blocks

Ever since I picked up SDL (which was not too long ago), I have used Code::Blocks with MinGW to develop... on Windows. Setting it up for SDL 1.2 was easy and quick.
Now I want to start with OpenGL 3.2, and since I already know SDL, I thought using it for OpenGL would be logical. So I downloaded SDL 2.0, which supports OpenGL 3.x, and tried to build the libraries.
I tried to make install with Cygwin, but it did not configure because I am on Windows. To get the .lib and .dll files, I followed the VisualC instructions and was able to generate them.
But I was pretty sure I wouldn't be able to use the *.lib files with MinGW. I couldn't.
So I tried to use reimp to convert the *.lib files to *.a. It did not work, all libraries were found to be "corrupt". Even glew32.lib which I downloaded and did not build myself. I am quite lost.
Can I even get it to work with MinGW, or do I have to switch to VisualStudio?
(I don't even know if VC++ 2010 Express Edition will be usable. The only reason I was able to build the VisualC libraries is because I used the Visual Studio Pro Trial. VC++ 2010 was not letting me do so earlier.)
Update:
I used MSYS to build the *.a and *.dll.a for both SDL 2.0 and GLEW. My project was linked properly and built without any problems. But, I am unable to run it.
I get the error "The application was unable to start correctly (0xc00007b)".
I know this problem is due to incorrect *.dll files. I have linked all the *.dll.a files I built, and I don't know why this problem is occurring.
What am I doing wrong?
(Here is the pastebin of the test program I wrote, but I doubt that the present problem is with the code.)
Update v2:
I solved it. I just put the *.dll files into the System32 folder, as well as the SysWOW64 folder.
Then, I just had to debug my code. Currently, you can't simply call SDL_Init(SDL_INIT_EVERYTHING) because there is no haptic support.
Now that I've got my stuff working, I'll get to developing. Thanks for your help.
You might want to try installing MSYS, which will provide you with a bash shell and the utilities for building a library on Windows.

how to compile c++ files with cygwin on windows 7

I have installed cygwin. But when I try to compile a c++ file it gives the following error:
/usr/lib/gcc/i686-pc-cygwin/4.3.4/cc1plus.exe: error while loading shared libraries: cygmpfr-1.dll: cannot open shared object file: No such file or directory
I checked in the lib folder there is no library with the name cygmpfr-1.dll. So is it that I have to put that dll in the lib folder. I have tried to search for the dll but could not find this dll so that i can download. I am just a beginner in C++. I have tried to setup cygwin support in netbeans as well, but there also if I try to run the sample files given, it throws the above error.
Can anybody give me a clue?
You need to install the gcc4-g++ package via http://cygwin.com/setup.exe
You only have gcc4 installed.
This will also install your missing dependencies.
If you're a beginner in C/C++, and you're running Windows, then why not take the simple route and get Visual-C++ Express, a free IDE from Microsoft for Windows.
It provides a GUI IDE (Integrated Development Environment), but if you prefer a text editor and command-line tools (compilers, debuggers, etc) those are available to you also, if you install Visual-C++ Express.
There are also tutorials and lessons to get you started.
On the other hand, if you really wanna focus on C++ on Linux, then you should probably uninstall Windows 7 right now.
I have had similar problems and I am no beginner. Try using the cygwin installer, and searching it for all versions of gmp. There generally are 32bit and 64 bit versions. Check everything you see and update your installation. Hope this helps. Some of these dll's you can find on the internet, but not the one you are looking for.