The MASM Forum

General => The Workshop => Topic started by: clamicun on December 15, 2017, 08:52:50 PM

Title: unresolved external symbol
Post by: clamicun on December 15, 2017, 08:52:50 PM
I have seen this error before but never thought much about it.

filename.obj : error link2001: unresolved external symbol _sqlite3_open
filename.exe : fatal error link1120 : 1 unresolved externals

I checked in the net but no very convincing explanation.
So what does it mean ?
0 warning 0 errors !!  ... no success

Some place in the net to enlighten me ?
Title: Re: unresolved external symbol
Post by: hutch-- on December 15, 2017, 09:30:00 PM
You are either missing an include file or missing a library. Find out where _sqlite3_open comes from and get the required file then include it.
Title: Re: unresolved external symbol
Post by: Jokaste on December 15, 2017, 10:16:23 PM
http://www.sqlite.org/download.html (http://www.sqlite.org/download.html)


After use PoLib to create to import library from the ".def"
Vortex also has utilities that could help you.
Title: Re: unresolved external symbol
Post by: clamicun on December 16, 2017, 10:58:07 AM
Hutch, Jokaste,
thank you, but that was not my problem. The sqlite problem I ""resolved"" 1 minute later .
I was/am after some material (book, pdf, site)  which explains what really is happening there. (like I said ...which could "enlighten" me.
A message "0 warnings 0 errors" and no result is hard to digest, because certainly something is very wrong. 
Title: Re: unresolved external symbol
Post by: aw27 on December 16, 2017, 12:26:36 PM
If I remember well the sqlite dll was cdecl not stdcall.
Title: Re: unresolved external symbol
Post by: jj2007 on December 16, 2017, 01:04:05 PM
Quote from: clamicun on December 16, 2017, 10:58:07 AMA message "0 warnings 0 errors" and no result is hard to digest, because certainly something is very wrong.

You build a project in two phases
- assemble
- link

The assembler sees a MyStuff proc in your code, and later on a call MyStuff. No problem.
But then there is an invoke GetTickCount but no GetTickCount proc ::)

So the assembler says "I don't know GetTickCount, error!"
Therefore we use an include file that contains GetTickCount PROTO to tell the assembler "don't worry, the linker will provide you with the address of that proc that you won't see in your code".

So with the PROTO, you get "0 warnings 0 errors" for the assembly phase, and afterwards the linker links everything together.
Except if it can't find GetTickCount, of course - then it complains "you cheated, there is no GetTickCount: unresolved external symbol".
Title: Re: unresolved external symbol
Post by: clamicun on December 17, 2017, 05:08:44 AM
jj thank you,
with this sqlite project I went the easier way. Using "Fresh IDE project - FreshLib reference - Flat Assembler" ... It comes with a sqlite3.inc file
which contains all protos you need.
There is an example in the net (https://stackoverflow.com/questions/11939956/how-can-i-use-sqlite3-with-masm32-on-windows) which looks ok. but produces exactely the "unresolved external error" .Do not know how this guy assembled it successfully.
Title: Re: unresolved external symbol
Post by: fearless on December 17, 2017, 06:47:49 AM
I compiled a static version of SQLite for assembler and uploaded it to my github libraries repository: https://github.com/mrfearless/libraries/tree/master/SQLite (https://github.com/mrfearless/libraries/tree/master/SQLite)

There is also a demo test RadASM project SQLiteTest by Mark Jones that i used to test the static libraries against and to verify it compiled and worked ok.

https://github.com/mrfearless/libraries/blob/master/releases/SQLite_x86.zip?raw=true (https://github.com/mrfearless/libraries/blob/master/releases/SQLite_x86.zip?raw=true)
https://github.com/mrfearless/libraries/blob/master/releases/SQLiteTest.zip?raw=true (https://github.com/mrfearless/libraries/blob/master/releases/SQLiteTest.zip?raw=true)

There is also an x64 version, but havent got round to testing that or verifying that the static x64 library is working.
Title: Re: unresolved external symbol
Post by: clamicun on December 17, 2017, 12:46:17 PM
Fearless, thanks ... Interesting, I check this out ...
Title: Re: unresolved external symbol
Post by: clamicun on December 18, 2017, 11:58:21 AM
Fearless,
your "SQLiteTest.asm from Github does it.
But not easyly.

First time it gave me:

0 warnings 0 errors and this...
warning LNK4044: unreecognized option "alternatename:__isa_available=__usa_available_default"; ignored
LINK fatal error LNK:1104: can not open file "uuid.lib"

I found an uuid.lib on my computer somewhere and put it into the SQLiteTest folder.
It worked.   ??