Build dynamic windows library (DLL) from libmcrypt with MinGW - windows

I'm trying to build libmcrypt library to use it with my project. It happened so, that they do not provide any kind of assistance.
First I've faced a problem with -no-undefined flag for gcc which is not further supported. I've replaced -no-undefined with -Wl,-no-undefined in makefiles and it does the trick.
But anyway I'am having problems. Lib is builded in .a files. I can see them in my C:\MinGW\msys\1.0\local\lib folder (it is analogue for /usr/local/lib folder in MinGW). But I need .dll library, not static .a .
So: what else must I change in makefiles to make MinGW build dll with header and debug info for it?

Related

Compiling on Windows using g++ and finding dependent .dlls

I'm making a 3D printer from scratch, hardware and software. I am using mingw to compile on windows and it works. But the .exe it produces relies on a bunch of .dlls in mingw's bin folder. So that means that either I'm doing something wrong or just don't know which .dlls need to go with my .exe.
The command I run to compile is:
g++ -o Slicer.exe "d:\Programming And Creativity\Slicer\main.cpp" "d:\Programming And Creativity\Slicer\slice.cpp" "d:\Programming And Creativity\Slicer\face.cpp" "d:\Programming And Creativity\Slicer\line.cpp" "d:\Programming And Creativity\Slicer\vertex.cpp"
If I try going to my project's folder and running g++ from there, it complains about a bunch of missing files. How can I reduce the numer of dll's needed to run the exe file?
I figured out a solution to my problem, I just had to add the --static flag.

Why does OMNet++ compiler gets errors for a precompiled package?

I have included an external package callled SoPlex (a folder of .cpp and .h files and the library files) into my OMNet++ project. I have already tested the package in Code::Blocks IDE and it works fine besides some warnings it had: warning: explicit conversion operators only available with -std=c++11 or -std=gnu++11.
It certainly was working in Code::Blocks IDE. But when I want to use it in my OMNet++ project it gives a lot of errors for the SoPlex package like in the picture:
It gives a lot of errors for just the code of SoPlex and not my OMNet++ project code.
Any idea what may cause the problem?
I have used MinGW to compile SoPlex package in Code::Blocks IDE. When I use MinGW GCC in OMNet++ instead of GCC for OMNet++ as current toolchain there is this error fatal error: omnetpp.h: No such file or directory.
Regarding the errors with the 3rd party library. Depending where you put the library inside the src folder, at least that directory must be added as an include dir, otherwise the header files will not be found by the compiler.
As for the problem with the omnetpp.h: OMNeT++ has it's own makefile generator which automatically adds the required include folder (omnetpp_root/include). The generic MinGW GCC toolchain does not. If you want to avoid extra work, always use the omnet toolchain to build your models.

Adding PCL (Point Cloud Library) to existing project with Makefiles

I have a problem with PCL: specifically I want to use it in the existing project with existing Makefiles. However, PCL is using CMake and I couldn't find how to add it to Makefile directly. Does anyone know how to do that?
First try to compile the one of the example provided in PCL website using CMake.
http://pointclouds.org/documentation/tutorials/pcl_visualizer.php
After compiling the above example, you will find various new files and a folder created by CMake in your directory.
Go to CMakeFiles/pcl_visualizer_demo.dir/ .
Open file named link.txt, which contains the terminal command which has various pcl(point cloud libraries) linked dynamically to the file.
command should look similar to the command shown below
/usr/bin/c++ -O3 -Wno-deprecated -s CMakeFiles/pcl_visualizer_demo.dir -o pcl_visualizer_demo -rdynamic -lpcl_common -Wl,-Bstatic -lflann_cpp_s -Wl,-Bdynamic -lpcl_kdtree -lpcl_octree -lpcl_search -lqhull -lpcl_surface -lpcl_sample_consensus -lpcl_io -lpcl_filters -lpcl_features -lpcl_keypoints -lpcl_registration -lpcl_segmentation -lpcl_recognition -lpcl_visualization -lpcl_people -lpcl_outofcore -lpcl_tracking /usr/lib/libvtkGenericFiltering.so.5.8.0 /usr/lib/libvtkGeovis.so.5.8.0 /usr/lib/libvtkCharts.so.5.8.0 /usr/lib/libvtkViews.so.5.8.0 /usr/lib/libvtkInfovis.so.5.8.0 /usr/lib/libvtkWidgets.so.5.8.0
You can include these libraries in your Makefile directly.
If you use different functions or pcl headers files, then first try compiling it using CMake and get the libraries linked and add it to your Makefile of previous project.
I tried this method for my project which worked perfectly fine. I tried pkg-config to link the libraries, which didn't work in my case. I was not able to find any other method that easily links all the required libraries.

Include mingw libraries in compiled file

I am using cmake to generate a Eclipse CDT MinGW Project. (Eclipse Version Kepler)
This is my Cmakelist:
project(IMGTODICOM)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(IMGTODICOM IMGTODICOM.cxx)
target_link_libraries(IMGTODICOM ITKReview ${ITK_LIBRARIES})
The code compile and run without problem in my computer, but in other PC it does not run. Some dll like libgcc_s_dw2-1.dll are required. I looked for this dll in my computer and I found it in C:\MinGW\bin. To solve the problem I copied the content of this folder in the other PC and the exe file finally run.
However, I am wondering if there is a better method to run the exe file in any windows pc adding these libraries in the compilation process.
I was reading and I should make that the compiler link to a static library. In Eclipse I tried to add the dll under properties>C/C++ Include Path and Symbols and under project Path>Libraries, but it does not work. I tried to modify the CmakeList but it also does not work.
I don't know why this problem and how can I include the content of C:\MinGW\bin in the exe file.
Many Thanks for any help
Yes, there is a way. For pure C code:
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static")
For C++ code:
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")

dev cpp win32 the program can't start because sqlite3.dll is missing

I am using dev c++ IDE which used ming gcc(i am not sure of it)
I wanted to use sqlite3 in my win32 c application
I downloaded sqlite3.dll and sqlite3.dev and used dlltool to create a .a file like libsqlite3.a and pasted in the lib folder of dev cpp and added this path in the project options -> parameters
i copied the header file sqlite3.h into the include folder(which i got from another website - http://www.opensource.apple.com/source/SQLite/SQLite-74/derived_source/sqlite3.h)
i executed the program and got the message 'the program can't start because sqlite3.dll is missing in your computer'
so i copied the sqlite3.dll into my working directory and then it worked
BUT
How to make the sqlite.* static while compiling?
I mean i thought by including the libsqlite3.a, the final exe will not be dependent of any external dll's.
So i want to know how to compile in a way that i will not be needing a dll and by doing so it makes my windows program standalone.
do i have a create a .lib file instead of .a file?
EDIT after answers and comments:
Besides, the devpak is working fine... yet i wanted to know how to include files to project or to create .a files so i am trying this way because if some components do not provide devpak then this will be the way we need to compile.. isn't it?
EDIT to show what i have done after the answer by CL and the two comments
This is how i have added the sqlite.c to project list
Here is the compile log
Compiler: Default compiler
Building Makefile:
"C:\Users\jayapalc\Documents\test-sqlite\Makefile.win"
Executing make...
make.exe -f "C:\Users\jayapalc\Documents\test-sqlite\Makefile.win" all
g++.exe -c sqlite3.c -o sqlite3.o -I"lib/gcc/mingw32/3.4.2/include"
-I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
sqlite3.c: In function `void strftimeFunc(sqlite3_context*, int,
sqlite3_value**)':
sqlite3.c:14727: error: invalid conversion from void*' tochar*'
The files i got in sqlite.org/sqlite-amalgamation-3071502.zip are
shell.c, sqlite3.h, sqlite3.c, sqlite3ext.h and i saw in other discussions that shell.c is not needed...
Besides, people were talking about gcc and g++... .
Apart from updating Dev-C++ itself, try this to compile sqlite.c as a C file:
Go to Project >> Project Options >> Files.
Find the C file we're talking about. Untick "Compile file as C++".
This should inform Dev-C++ that it should invoke gcc.exe, and not g++.exe.
If you don't want to compile sqlite yourself by adding it to your project, you can try passing the -static flag to GCC/G++ to force it to link libsqlite.a statically.
Just include the sqlite3.c file in your project.
You need only this filed, and it must be compiled as C, not C++.
Apparently, Dev-C++ does not allow mixing C and C++ source files in one project.
Instead, you could try to compile sqlite3.c as C and then include the generated .o file into the C++ project (on the Linker page).

Resources