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

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).

Related

Purpose of include folders in cross compiler

I have installed GCC cross compiler for Raspberry Pi to my Ubuntu 20.04 to opt folder. Now When I create new cross compile project I have list of include in my Eclipse project explorer:
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/arm-none-linux-gnueabihf/include
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/arm-none-linux-gnueabihf/libc/usr/include
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/10.2.1/usr/include
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/lib/gcc/arm-none-linux-gnueabihf/10.2.1/usr/include-fixed
How Eclipse knows these include folders?
What is purpose of all of these folders? What kind of includes they are defined for?
Suppose I need to use SDL2 library. Where I should place it's header and binary?
As explained in this article (which is a little dated) https://www.eclipse.org/community/eclipse_newsletter/2013/october/article4.php CDT will try to detect built-in compiler symbols and include paths running the compiler with special options and parse the output of this special run. The command will be probably something like: arm-linux-gnueabihf-cpp -v /dev/null -o /dev/null supposing the compiler you are using is arm-linux-gnueabihf-gcc.
All these folders contains include files like stdio.h , stdlib.h ... of libc , libm ... and also some arm specific header files.
If you are not 100% sure, install the cross compiled in a directory all by itself and add the include directory to your eclipse project.

Eigen library + Code::Blocks

Trying to use Code::blocks with the library Eigen. Using windows vista. With some help from a forum I got this command to compile a sample program:
C:\Users\Me\Desktop\eigen>g++ -I C:\Users\Me\Desktop\eigen\eigen3
-o test2.exe C:\Users\Me\Desktop\eigen\test.cpp
But if I cd anywhere else (other than my folder containing test.cpp) and try to build, I get a permission denied error.
On code blocks I started a new project and went to Settings->Compiler->Linker settings->Link libraries-> and added C:\Users\Me\Desktop\eigen
And also added the same link under build options. I got this error:
C:\Users\Me\Desktop\GUI\vector\main.cpp|2|fatal error:
Eigen/Dense: No such file or directory|
The pages I followed were:
http://eigen.tuxfamily.org/dox/GettingStarted.html
https://github.com/Microsoft/AirSim/blob/master/docs/install_eigen.md
As eigen has already stated, all you have to do is copy the headers from the eigen folder to the include folder of your compiler (or just make sure your compiler can find your eigen folder).
Just copy the entire Eigen folder from drive/(where eigen is)/eigen/ to the include folder of code blocks in CodeBlocks\MinGW\include.
After that, all you have to do is make sure in Settings->Compiler in the Search directories tab, the compiler tab has the location to include and linker tab to lib, and the same goes for your build options.
There is absolutely no use of adding the Eigen folder to link libraries option of the linker tab, since Eigen has no libraries and works only with headers.

How to use SDL2 with Qt Creator - Windows

I was struggling with using SDL2 and Qt Creator and found some threads here on SO that were mostly helpful but nothing that put it all together for SDL2 and Qt Creator on Windows 10. The main issue was that I could not use the console for I/O at the same time as SDL2 and following the other recommendations, a number of different things went wrong.
There were two keys:
Which SDL2.dll file to use and which directory to place it.
Some said use the SDL2.dll file download from the SDL website. Others said put this file in the main project directory, which did not work for me. What worked for me was first doing a build of my project (which failed) but creates a "build-..." directory. Then, taking the SDL2.dll file from installDir\SDL2-2.0.5\i686-w64-mingw32\bin and placing it in the "build-..." directory.
In the project.pro file, adding manually:
INCLUDEPATH += installDir/SDL2-2.0.5/i686-w64-mingw32/include
LIBS += -L installDir/SDL2-2.0.5/i686-w64-mingw32/lib -lmingw32 -mwindows -mconsole -lSDL2main -lSDL2
CXXFLAGS = -std=c++11
To be honest, I don't know if all of the calls in LIBS are needed, but it's now working perfectly for me and I thought I'd share some knowledge.
Where to put the DLL
The dll, is required to be in a directory which match one of the following rules:
Is part of the $PATH$ environment variable
Is in the same directory than the executable
Is in a directory which is actively specified in your code and loaded "manually".
In my case, I just moved those DLL to my /bin folder.
Libs and includes
Includes are required for the compiler, for this purpose, both of the following possibilities match:
Copy the SDL includes in the compiler include directory.
Add the include path to the project using INCLUDEPATH as explained by #launchpadmcquack.
Libs are required by the linker, for this purpose, both of the following possibilities match:
Copy the SDL libs in the compiler lib directory.
Add the lib to the project using LIBS as explained in the question.
Considering the library list, SDL2 is required, others depends on you specific projects. E.g. In my case I do not link any of the mingw32, mwindows or mconsole.
Additional note: You may specify C++11 with the CONFIG parameter:
CONFIG *= c++11

How to build a C dependency of go project in a subdirectory

I am writing a Go wrapper for a C library in Go. The problem is, that the C library is not available on many Linux distributions, so I want a solution where i "go get github.com/me/mylibrary" does not require anybody to have the library installed.
One solution would be to just add the source of the library into a sub directory. Then when my project is build with go get I need to automatically build this library, too. But I have no idea how I can automate this.
Alternatively I could have a script that downloads the source, extracts and builds it
But I have no Idea how to connect these build steps with the go build tool.
linking a static library is also not the easiest.
#cgo linux LDFLAGS: ./MyLib/lib/libMyLib.a -lstdc++ -lm -lX11
works as long as i build from my library, but as soon as I want to build from another project the relative path is from that project and not from my library, so it fails.
As per http://golang.org/cmd/cgo/#hdr-Using_cgo_with_the_go_command
When the Go tool sees that one or more Go files use the special import
"C", it will look for other non-Go files in the directory and compile
them as part of the Go package. Any .c, .s, or .S files will be
compiled with the C compiler. Any .cc, .cpp, or .cxx files will be
compiled with the C++ compiler.
So you can include the C library source in your repository and go will build it automatically. That page also explains how to pass build flags to the compilers and probably anything else you might need to know.

Xcode: setting to enable C++ even when no C++ sources are in the project?

I have an Objective-C/Cocoa project that incorporates a static library. That static library has some object files that have C++ in them.
I've found that if the project that I'm using the library in contains no other C++ in it, the link fails (can't link new/delete/etc). But simply adding a single (empty) .cpp file to the project causes the link to succeed.
In practice, what happens is that the build will invoke g++ instead of gcc when there is any cpp, which succeeds. No other difference in the build is apparent to me.
Is there an explicit switch I can use to link in this library without using the dummy cpp file in the project?
(This is mostly a curiosity question-- it's not the end of the world to put in one empty file. :) )
Thanks.
try to link libstdc++
gcc main.c -lstdc++
or in Xcode:
Project->Edit Project Settings
To the config section "Other Linker Flags", add -lstdc++.

Resources