0

Installed https://www.mingw-w64.org/ and added the libs but still getting this error:

Info: Internal Builder is used for build
g++ -std=c++11 -O3 -Wall -c -fmessage-length=0 -o main.o "..\\main.cpp" 
g++ -std=c++11 "-LF:\\MinGW\\lib" -o test.exe main.o -lpsapi -lpthread -lm -ldl 
main.o:main.cpp:(.text.startup+0x1f): undefined reference to `sqlite3_open'
main.o:main.cpp:(.text.startup+0x36): undefined reference to `sqlite3_errmsg'
f:/mingw/bin/../lib/gcc/i686-w64-mingw32/4.8.3/../../../../i686-w64-mingw32/bin/ld.exe: main.o: bad reloc address 0x36 in section `.text.startup'
collect2.exe: error: ld returned 1 exit status

Used the installer and choosed "Native Windows" + "i686".

The code:

#include <iostream>
#include <windows.h>
#include <string>
using namespace std;

#include <sqlite3.h>
sqlite3 *db;

int main() {
    int open = sqlite3_open("test.db", &db);
    if( open ) {
        cerr << "Can't open database: " << sqlite3_errmsg(db) << endl;
        sqlite3_close(db);
        exit(1);
    }
    return 0;
}
Richard
  • 43
  • 4

0 Answers0