This is a lesson to beginners about "Undefined references to", what happened to me. I have a library of my own subroutines/functions called jlib. So when I add new routines to the library, I run MAKEJLIB.BAT, which starts a program called bldjlib.exe made by me. This program collects recursively all routines from different directories to be included in single source file called jlib.bas. Then MAKEJLIB.BAT calls fbc the usual way: "c:\bas-free\fbc -v -exx -lib jlib.bas". Then the .BAT copies jlib.bi and libjlib.a to to the right directories (c:\bas-free\inc, c:\bas-free\lib\win32). Everything was fine; no error messages! But when I edited my old application source code and compiled it, I got many errors like: "Undefined references to ISHELP@22" etc. What's wrong in the world? Really?
Well, I had reinstalled my Windows 10, and of cource Microdisaster had blurred some way bldjlib.exe. When I compiled my library again, bldjlib.exe wrote only next header lines to collect file jlib.bas:
'****************************
'JLIB.BAS (made by c:\ut\bldjlib in MAKEJLIB.BAT)
'jlib routines assembly file for jlib compilation.
'Indents and comment lines removed as unnecessary.
'****************************
#include once "c:\bas\arc\jlib\jlib.bi"
There really was no source code of routines. So if english is not your native language, please differ those words "declare" and "define". "Define" means real source code and it has to be available in compilation either precompiled in library or in source code modules in call to fbc.exe as "subsource.bas". You can declare your routine and call it in your application, but if linker (ld.exe) have no object code to link to .exe, you will get those confusing "Undefined references" messages.
Undefined references to
Re: Undefined references to
In fact, this is so common and confusing error message, that it should be available and searchable in all versions of FB manuals. The message of ld.exe really don't tell anything to us newbies. How and what to fix?
Re: Undefined references to
I would say that the "right directory" in in fact the same folder as your working code, to begin with.
To test your code is working there is no sense in sending inc and .a files into your fb distribution.
Get them all together first to iron out the problem.
Try using alias to see if it helps the linker.
The linker complains if it cannot run a function/sub from the lib.
There could be several reasons for this, are they declared properly after your edit?
You can send these files to inc and lib when you are satisfied they are working in your (.bas + .bi + .a) directory.
To test your code is working there is no sense in sending inc and .a files into your fb distribution.
Get them all together first to iron out the problem.
Try using alias to see if it helps the linker.
Code: Select all
declare function printf cdecl alias "printf"(as zstring ptr,...) as long
printf(!"%s\n","hello")
sleep
There could be several reasons for this, are they declared properly after your edit?
You can send these files to inc and lib when you are satisfied they are working in your (.bas + .bi + .a) directory.