How do I get the static versions of the modules? - c++

I'm working on a game in SFML. It runs correctly on my computer, but if I send it to another computer then when I try to run it I get errors about not being able to find libraries. I did some research and I found that the reason is because I was using dynamic libraries, and to get the program to work on its own I need the static libraries. But how do I get those? They aren't in my sfml folder. I tried doing more research but I can't find a way to build or download those libraries.

Just go to your sfml Src directory and look for the /bin folder. Copy the following DLLs to your game folder where your exe is located:
DLLs
sfml-graphics.dll
sfml-window.dll
sfml-audio.dll
sfml-network.dll
sfml-system.dll
On Linux, install libsfml-dev on target computer.

I am sure you are using mingw compiler. You can add static arguments and try.
-static-libgcc -static-libstdc++
If this doesn't work try to search the two DLL files in your standard compiler path /bin folder and place them where your exe is located.

Related

Why have .a files been installed in Windows with Qt online installer?

I installed Qt 6.3.1 libraries pre-built with MinGW 11.2.0 64-bit using the online installer. The application crashes without entering the main function when I use any of Qt libraries in the Qt Creator while there is no problem if I use only C++ standart library. I guess the problem is in linking. Because I realized that there are .a files in the folder C:\Qt-mingw\6.3.1\mingw_64\lib, even though I am using Windows 10. Why are .a files installed instead of .lib files? How to solve this issue?
Here are the the selections that I made when installing Qt libraries using the online installer:
After learning that the problem may be due to duplication of some library from here, I saw using dependency walker that my program uses libstdc++-6.dll in system32 instead of qt-mingw installation. So the problem solved when I copied that dll into my app's folder. But I wonder how to solve this by changing the path without copying libstdc++-6.dll into app's folder. Because even though I put qt-mingw bin folder at the very beginning in system path, app uses still the one in system32.

No DLL dependency Mingw under Netbeans

I'm trying to get back to C++ using Mingw and Netbeans but all released .exe requires some .dll files if ran on another PC.
What should I do to add those library to the released .exe file. [I do not have too much experience in real C++ programming]
Please tell us what dll's are missing. but often you can find them in the bin folder of mingw. If you release your program, put those dll's where your exe is.
Alternative: use static linkage
Edit:
You can get this file from the bin folder of your mingw installation. Copy it to your exe
Compile with linker flags: -static-libstdc++ and -static-libgcc

Add required libraries to build from CDT

In a project I am working on I depend on a couple of external libraries that are necessary for the program to run. On my local machine they can be found in usr/local/lib and everything works like a charm.
Now, when I build my Release I want these libraries to be added to the build
(I want to end up with my executable and all necessary libs) and configure it, such that when I run the program from commandline, it knows the libraries are in lib.
I could manually add all the libraries in this folder on my local machine and configure my project so that it can find the libraries here, but, even using variables, it still inserts a local path, so using it on other machines does not work. Or is there a way to do this starting from the project path?
Is this possible using CDT?
If you use relative paths to the project folder, that should be totally portable, as long as the other machines can run such libraries. For example if your project is in /home/Fristi/project, you could just copy all your static libraries into ./libs (which actually points to /home/Fristi/project/libs and add ./libs in your makefile or CDT configuration.

Using MinGW to compile a SFML project

Okay, so I have a C++ project that uses SFML, and I want to be able to compile it from the CMD using MinGW. I have it so I can compile.cpp's, however, I just need to know what more I have to do in order for it to work with SFML. I tried compiling it with CodeBlocks and MinGW, and it works fine, until I try to run it, at which point it tells me that sfml-system.dll is missing from my computer. Does this mean I installed it incorrectly? I followed the CodeBlocks installation down to the letter, from what I could tell... I put the include\SFML in the include\ of MinGW, and I put all the *.a's from lib\ into the \lib of MinGW as well.
Thank you for the help you can give!
Ok, so if it builds well and links with the sfml-system.dll at link time then there is no real problem. All you need to do is copy the sfml-system.dll (or make a link to it) in the directory, where the built .exe file is. That would make the .exe find the required library.
libgcc_s_dw2-1.dll is just inside bin folder, on latest MinGW releases.
Copy to .exe folder, it should run.

Compiling libpng and using it with netbeans and mingw

I have only previously used visual studio for developing c++ but I've just moved to netbeans and am having some issues.
I got mingw installed so that my projects will compile but I dont know how to add external libraries to that. I want to use a static library, not a dll.
The library I specifically am looking at is libpng
I hope this isn't too IDE specific, I'm also looking to know how to prepare the library.
Windows OS.
I figured it out more or less. I used the cmake gui, configured for msys make and mingw g++ and gcc, on the zlib source directory and then ran msys make and make install on the output directory. After that I did the same on libpng, but I had to add some variables to point to the zlib include and library directories within cmake.
Then in netbeans, I right clicked>>properties on my project and added include and lib location for each of the two libraries. I also could have copied the files into my mingw directories.
Now I'm just stuck with this issue.