Unable to compile or run sqlite3 using Visual Studio 2015 - c

I'm trying to compile the source of sqlite3.c and shell.c I downloaded from the SQLite website using Visual Studio 2015. I created DLL project sqlite3 and put the sqlite3.c source into it. Then I created project sqlite3shell and put shell.c source into it. I added include "stdafx.h" into both. When I compiled both projects the DLL did not produce a .lib file, so the compile of sqlite3shell got the error LNK1104 cannot open sqlite3.lib.
I manually created a .lib file using this solution. Then the sqlite3shell program compiled successfully. But when I went to run the program, I got the error The application was unable to start correctly (0xc000007b). Looking into this error is seems one reason it could be caused is by trying to access a 64-bit program from a 32-bit program. But everything was created using the x86 configuration.
Is there some way to have the DLL compile produce the correct .lib file? Or if that won't fix the problem, is there something I can do to prevent the 0xc000007b error?

In case someone else should have this problem, I have found the solution. There were 2 lines that specified the define of SQLITE_API. I added the export to the define like this: # define SQLITE_API __declspec(dllexport). Apparently there were no exports, so that was why the .lib file was never created. With the change, the .lib and .exp files were created and then the program didn't get the 0c000007b error.

Related

How to use VC++ compiler in command line(Windows)?

I tried to use VC++ commandline, instead of MinGW compiler for windows system programming. I wrote a simple hello world program and tried to compile it, then i got this error message.
test2.c(1): fatal error C1083:'stdio.h': No such file or directory
I also added "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx86\x86" directory (where c1.dll lives) to the System Envionment Variable(PATH).
How can I fix this issue? Other tutorials don't give much information about VC++. (A lot of MinGW compiler tutorial out there btw)
You should use visual studio command line if you want to compile or run program with the help of vc++ compiler.
Else all information related to setting environment variables ETC. resides in this MSDN document.

Visual Studio Community 2017 cl linker won't link GTK3 libraries?

I am writing code in C using GTK as GUI toolbox. I installed GTK3 via MSYS2 and managed to compile and build using GCC (TDM-Dragon) alright.
However, lately I am trying to compile and link using cl included in Visual Studio Community 2017 (heard it is faster and more stable). With this, I am having a hard time building an application. I am loosely following this tutorial:
http://www.tarnyko.net/en/?q=node/22
I created a BAT file and invoke it from the VS 2017 command prompt:
set GINC_PATH="C:\msys64\mingw64\include"
set GLIB_PATH="C:\msys64\mingw64\lib"
cl gtk3test.c -I"%GINC_PATH%\gtk-3.0" -I"%GINC_PATH%\glib-2.0" -I"%GLIB_PATH%\glib-2.0\include" -I"%GINC_PATH%\pango-1.0" -I"%GINC_PATH%\cairo" -I"%GINC_PATH%\gdk-pixbuf-2.0" -I"%GINC_PATH%\atk-1.0" -Dinline= /link /LIBPATH:%GLIB_PATH% gtk-3.lib gdk-3.lib gobject-2.0.lib glib-2.0.lib
This compiles alright, gives me gtk3test.obj. However, the linker returns the following error:
LINK : fatal error LNK1181: cannot open input file 'gtk-3.lib'
What am I doing wrong here? How would it be possible to use cl for linking GTK3 applications?
Thank you all in advance!
Xuttuh
Please check if you have gtk-3.lib in your folder path [%GINC_PATH%]. Even I have this issue using GTK+3.0, the package configuration is not giving the proper library reference.
The gtk library is something like gtk-win32-3.0.lib available inside lib folder %GINC_PATH%\lib in your case.
I still have issues in linking GTK libraries in my visual studio application even after providing the needed library references in Linker.

Linking a lib library in C using Visual Studio 2013

I added to Visual studio Project->Properties->Linker->Input->Additional Dependencies the x.lib file. My build was successful but program didnt start because after start it wrotes: The program cant start because of x.dll is missing from your computer. Why is it looking for x.dll and not x.lib?
For dynamic linking:
x.lib is used for compiling, which contains the linking information of library functions. When compiling, compiler just check whether these functions exist. To understand it simply, compiling will give the way to locating these functions in dll files.
While x.dll is dynamic link library which contains the implementations (maybe not that accurate) of these functions. If you didn't set dll right, the program cannot execute the corresponding functions. dll is the actually executable file, not lib.

VS Visual GDB intellisense not finding library, but compiles properly

In particular, #include "sqlite3.h" gives an error [Clang Intellisense] Error: 'sqlite3.h' file not found in Visual Studio.
Everything works fine when compiling/running, but the intellisense errors are annoying.
I've installed sqlite3-dev and ran updates/upgrades.
I see sqlite3.h in the usr/include directory which is included in the list of intellisense directories under project properties.
sqlite3 is included in the Library names (Makefile settings -> Config settings)
Is my path going to the wrong library or am I just missing something simple? I don't see the sqlite.c file in there and looking the the .h file, I don't see the functions I am using (from an example) like SQLITE_OK or sqlite3_free.
Again, everything works, it's just the intellisense that doesn't work. At least from what I can tell so far.
Oh, and the code is running on raspbian if that matters.
Yes, I experience the same the first time I open the solution. But I managed to get rid of it by opening one of the included header files and a clean Rebuild.
my VS version is 2015

Statically Linking glib

I'm trying to statically link glib into my C program. I'm not sure what's the best way to do this. I downloaded the code and put it in a subdirectory called glib-2.36.4. I added "-Iglib-2.36.4" when using gcc. The glib.h is in the glib-2.36.4/glib directory and in that file there are references to other header files under the glib directory (such as #include ).
I'm not sure why that is since both glib.h and these other header files are at the same level (in glib subdirectory). I got a compile error due to galloca.h not being found (even though it's there). So I copied glib.h up one level and those errors went away. I then got an error about a missing glibconfig.h. I copied that from my usr directory and that error went away. I compiled my project and now I'm getting an error about undefined reference to g_ptr_array_new. I guess this must be because I haven't actually compiled glib. I had tried to build glib, but when I typed "./configure", but I got this message:
checking if arpa/nameser_compat.h is needed... configure: error: could not compile test program either way
I did install glib using yum, but I really want this code to run even if glib is not installed on a machine.
You need to install both glib and glib-dev via yum, compile using ./configure, (take a look in the ./configure script to see if there are any flags you need to supply or defines you need to produce the static build), without moving any files about, and then you need to compile your code using -i path/to/glib/includes and link with -L path/to/built/static/library

Resources