Any ideas, anyone?ld: /home/norman/FreeBASIC/bin/../lib/freebasic/linux-x86_64/libbig_int.a(basic_funcs.o):basic_funcs.c(.text+0x43): undefined reference to '_assert'
Compile Error On Ubuntu
Compile Error On Ubuntu
I have a small program I wrote as a Windows application. I take the code to my Linux system and try to compile it and I get repeated errors, all the same, like below:
Re: Compile Error On Ubuntu
Your file basic_funcs.bas contains a call to a function named _assert, but this function isn't declared.
If this function is in the library libbig_int.a, you've to DECLARE it in the FB code.
If this function is in the library libbig_int.a, you've to DECLARE it in the FB code.
Re: Compile Error On Ubuntu
No, that's not correct. This is a link error, not a compile error, so isn't caused by a missing declare, and anyway libbig_int is a library written in C, not a FB module.
I'm surprised you have a lib/freebasic/linux-x86_64/libbig_int.a file. Was that included with the copy of FB you downloaded, or did you install it?
My libc.so doesn't have an _assert function (only assert and __assert) and I don't think the extra underscore was added by the compiler, so I think maybe that libbig_int.a was compiled on a different system and isn't compatible with the system libraries on your system?
I'm surprised you have a lib/freebasic/linux-x86_64/libbig_int.a file. Was that included with the copy of FB you downloaded, or did you install it?
My libc.so doesn't have an _assert function (only assert and __assert) and I don't think the extra underscore was added by the compiler, so I think maybe that libbig_int.a was compiled on a different system and isn't compatible with the system libraries on your system?
Re: Compile Error On Ubuntu
What's incorrect?TeeEmCee wrote:No, that's not correct.
You talked about a compile error. I know, a message starting with ld: is comming from the linker.
And I think that we agree, that the linker couldn't bind the function named _assert.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Compile Error On Ubuntu
Link the right C runtime and the open reference are solved :-)
Or you used a wrong define (or the right define are missed -D NDEBUG) while you build the static C library !
Joshy
Or you used a wrong define (or the right define are missed -D NDEBUG) while you build the static C library !
Joshy
Re: Compile Error On Ubuntu
You wrote "If this function is in the library libbig_int.a, you've to DECLARE it in the FB code" and that was what was incorrect. (I assumed you meant "you've got to DECLARE it")TJF wrote:What's incorrect?TeeEmCee wrote:No, that's not correct.
Oh, when I said "compile error" I meant specifically an error produced while converting from FB to object file, but now I realise that might be confusing.
Re: Compile Error On Ubuntu
Based on an assumption you tell everybody that my entire statement is not correct? That's not quite respectable.TeeEmCee wrote:... I assumed you meant ...TJF wrote:What's incorrect?TeeEmCee wrote:No, that's not correct.
Re: Compile Error On Ubuntu
Well, sorry, but I took what you wrote literally. Taken literally, it was wrong, and I think I'm right to point that out. I don't understand why you've taken offence, but it wasn't my intention to cause any.
Re: Compile Error On Ubuntu
TeeEmCee wrote:Well, sorry, but I took what you wrote literally. Taken literally, it was wrong, ...
- One of us translated and provided more then 20 high-quality header sets for C libraries, even complex ones like GDA, LDE or GTK.
- One of us developed several tools to auto-create FB headers from C source and vice versa.
- One of us knows what he is talking about when it comes to linking foreign libraries to FB code.
You shouldn't confuse beginners!
Re: Compile Error On Ubuntu
I hardly read the forums and I wasn't very aware of your good work.
But I never assumed you didn't know what you were talking about. You could have claimed your expertise without attacking me. Do I really need to refute your bad-faith claim that I don't understand linking? I deal with arcane details of mixing C/C++/FB code all the time. I do it far more than is reasonable. I worked on the FB Android and Mac ports including system headers and linking and wrote two parsers for FB function declarations as part of transpilers to/from FreeBasic. I've checked the source code for quite a few linkers, assemblers, and object file parsers in order to understand behaviour, especially related to FB (e.g ports).
I got a bit upset that you attacked me after I tried to de-escalate this argument, and now I have to try yet again?? I said "sorry" genuinely, not ironically! Guess I need to stay out of your way.
But I never assumed you didn't know what you were talking about. You could have claimed your expertise without attacking me. Do I really need to refute your bad-faith claim that I don't understand linking? I deal with arcane details of mixing C/C++/FB code all the time. I do it far more than is reasonable. I worked on the FB Android and Mac ports including system headers and linking and wrote two parsers for FB function declarations as part of transpilers to/from FreeBasic. I've checked the source code for quite a few linkers, assemblers, and object file parsers in order to understand behaviour, especially related to FB (e.g ports).
The problem here is that I kept talking about the error in the original post, and complained that your statement had nothing to do with that error. (Wasn't trying to blame you for misunderstanding after skimming, that's understandable.) You took offence and defended the things you wrote as true if taken in isolation without reference to any error message. I kept trying to address the original question, rather than change topic to declaring functions.TJF wrote:My statement isn't incorrect, neither literally nor in any other case.
I got a bit upset that you attacked me after I tried to de-escalate this argument, and now I have to try yet again?? I said "sorry" genuinely, not ironically! Guess I need to stay out of your way.
Re: Compile Error On Ubuntu
IMHO:
- A non declared neither defined procedure name induces a compiler error:
- A non declared neither defined procedure name induces a compiler error:
Code: Select all
'Declare Sub subroutine()
subroutine()
- An non defined but declared procedure name induces a linker error:Compiler output:
FreeBASIC Compiler - Version 1.08.0 (2019-12-08), built for win32 (32bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone
target: win32, 686, 32bit
compiling: C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.bas -o C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.c (main module)
C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.bas(3) error 42: Variable not declared, subroutine in 'subroutine()'
Code: Select all
Declare Sub subroutine()
subroutine()
Compiler output:
FreeBASIC Compiler - Version 1.08.0 (2019-12-08), built for win32 (32bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone
target: win32, 686, 32bit
compiling: C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.bas -o C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.c (main module)
compiling C: C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\bin\win32\gcc.exe -m32 -march=i686 -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fwrapv -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Wno-format -masm=intel "C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.c" -o "C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.asm"
assembling: C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\bin\win32\as.exe --32 --strip-local-absolute "C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.asm" -o "C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.o"
compiling rc: C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\bin\win32\GoRC.exe /ni /nw /o /fo "c:\users\fxmam\documents\mes outils personnels\freebasic-1.07.0-win32\bin\win32\res\fblogo.obj" "c:\users\fxmam\documents\mes outils personnels\freebasic-1.07.0-win32\bin\win32\res\fblogo.rc"
linking: C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\bin\win32\ld.exe -m i386pe -o "C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.exe" -subsystem console "C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\lib\win32\fbextra.x" --stack 1048576,1048576 -s -L "C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\lib\win32" -L "." "C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\lib\win32\crt2.o" "C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\lib\win32\crtbegin.o" "C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\lib\win32\fbrt0.o" "C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.o" "c:\users\fxmam\documents\mes outils personnels\freebasic-1.07.0-win32\bin\win32\res\fblogo.obj" "-(" -lfb -lgcc -lmsvcrt -lkernel32 -luser32 -lmingw32 -lmingwex -lmoldname -lgcc_eh "-)" "C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\lib\win32\crtend.o"
linking failed: 'C:\Users\fxmam\Documents\Mes Outils Personnels\fbc1.08.0.St_W\bin\win32\ld.exe' terminated with exit code 1
C:\Users\fxmam\Documents\Mes Outils Personnels\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.o:fake:(.text+0xcf): undefined reference to `SUBROUTINE@0'
Re: Compile Error On Ubuntu
@fxm:
We're talking about compiling against a library. Example
We're talking about compiling against a library. Example
Code: Select all
TYPE AS LONG size_t
' correct:
'DECLARE FUNCTION memcpy CDECL LIB "c" ALIAS "memcpy"(BYVAL AS ANY PTR, BYVAL AS ANY PTR, BYVAL AS size_t) AS ANY PTR
' incorrect (name isn't present in the binary)
DECLARE FUNCTION memcpy CDECL LIB "c" ALIAS "_assert"(BYVAL AS ANY PTR, BYVAL AS ANY PTR, BYVAL AS size_t) AS ANY PTR
memcpy(0, 0, 0)
Perhaps I should have writtenfbc -exx -w all "basic_funcs.bas"
basic_funcs.o: In Funktion `main':
basic_funcs.c:(.text+0x6d): undefined reference to '_assert'
, so that more people understand what's going on.TJF doesn't wrote:If this function is in the library libbig_int.a, you've to DECLARE it properly in the FB code.
Re: Compile Error On Ubuntu
Yes, it's clearer.
The alternate name (after Alias) is the one visible to the linker when linking with the library. If this name is incorrect, this will cause a linker error.
The alternate name (after Alias) is the one visible to the linker when linking with the library. If this name is incorrect, this will cause a linker error.