SQLite Forum

What am I doing wrong to get errors when trying to compile amalgamation file in Linux
Login
Hello, I'm attempting to compile a C file with the sqlite3 amalgamation and get the following errors.  I tried on versions 3.34.0 and 3.35.5 and am using Manjaro Linux.  I'm certain that I compiled the same on Windows 7 without any issue; and am sure the cause is that I don't know something I should about Linux.

Would you please let me know what I'm doing wrong?  Thank you.

$ gcc -O2 -c sqlite3.c -- generates the sqlite3.o file without error.

$ gcc -O2 sqlite3.o myfile.c -o myfile.exe

/usr/bin/ld: sqlite3.o: in function `pthreadMutexTry':
sqlite3.c:(.text+0x3c65): undefined reference to `pthread_mutex_trylock'
/usr/bin/ld: sqlite3.o: in function `sqlite3ThreadCreate':
sqlite3.c:(.text+0x867c): undefined reference to `pthread_create'
/usr/bin/ld: sqlite3.o: in function `vdbeSorterJoinThread':
sqlite3.c:(.text+0x8718): undefined reference to `pthread_join'
/usr/bin/ld: sqlite3.o: in function `pthreadMutexAlloc':
sqlite3.c:(.text+0x12ed6): undefined reference to `pthread_mutexattr_init'
/usr/bin/ld: sqlite3.c:(.text+0x12ee3): undefined reference to `pthread_mutexattr_settype'
/usr/bin/ld: sqlite3.c:(.text+0x12ef6): undefined reference to `pthread_mutexattr_destroy'
/usr/bin/ld: sqlite3.o: in function `unixDlError':
sqlite3.c:(.text+0x29e2f): undefined reference to `dlerror'
/usr/bin/ld: sqlite3.o: in function `sqlite3VdbeExec':
sqlite3.c:(.text+0x830ba): undefined reference to `pthread_join'
/usr/bin/ld: sqlite3.o: in function `unixDlClose':
sqlite3.c:(.text+0x4674): undefined reference to `dlclose'
/usr/bin/ld: sqlite3.o: in function `unixDlSym':
sqlite3.c:(.text+0x4687): undefined reference to `dlsym'
/usr/bin/ld: sqlite3.o: in function `unixDlOpen':
sqlite3.c:(.text+0x4699): undefined reference to `dlopen'
collect2: error: ld returned 1 exit status