• Welcome to PlanetSquires Forums.
 

Linker error from WinFBE but compiles ok with fb.exe from command line

Started by Bruce Huber, December 02, 2017, 05:06:09 PM

Previous topic - Next topic

Bruce Huber

Just trying WinFBE (ver. 1.5.6) for the first time. Cool! But I have a problem with linking during a build.

The linker problem is only with WinFBE.

The application (console app) compiles with fb.exe (64-bit ver. 1.05.0) from the command line with no messages or errors and the application runs just fine.

The app is a port (by FB forum admin @counting_pine) of the PCG PRNG.

My somewhat cleaned up source (still trying to figure out the ported .bi file) and WinFBE project files are attached as a .zip - (too large to inline).

Compiler log with link error:

(WinFBE Compiler Log)...
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
standalone
target:       win32, 486, 32bit
compiling:    D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.bas -o D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.asm (main module)
assembling:   D:\FreeBASIC\bin\win32\as.exe --32 --strip-local-absolute "D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.asm" -o "D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.o"
compiling rc:               D:\FreeBASIC\bin\win32\GoRC.exe /ni /nw /o /fo "D:\FreeBASIC\00_BRUCE\PCG32_FULL\resource.obj" "D:\FreeBASIC\00_BRUCE\PCG32_FULL\resource.rc"
linking:      D:\FreeBASIC\bin\win32\ld.exe -m i386pe -o "D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.exe" -subsystem console "D:\FreeBASIC\lib\win32\fbextra.x" --stack 1048576,1048576 -s -L "D:\FreeBASIC\lib\win32" -L "." "D:\FreeBASIC\lib\win32\crt2.o" "D:\FreeBASIC\lib\win32\crtbegin.o" "D:\FreeBASIC\lib\win32\fbrt0.o" "D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.o" "D:\FreeBASIC\00_BRUCE\PCG32_FULL\resource.obj" ".\.wfbe\pcg_advance64.o" "-(" -lfb -lgcc -lmsvcrt -lkernel32 -luser32 -lmingw32 -lmingwex -lmoldname -lgcc_eh "-)" "D:\FreeBASIC\lib\win32\crtend.o"

(All of the warnings are like this)...
.\.wfbe\pcg_advance64.o:fake:(.text+0x0): multiple definition of `pcg_rotr_8'
D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.o:fake:(.text+0x0): first defined here
.\.wfbe\pcg_advance64.o:fake:(.text+0x40): multiple definition of `pcg_rotr_16'
D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.o:fake:(.text+0x40): first defined here
.\.wfbe\pcg_advance64.o:fake:(.text+0x80): multiple definition of `pcg_rotr_32'
D:\FreeBASIC\00_BRUCE\PCG32_FULL\pcg__small-test.o:fake:(.text+0x80): first defined here

(And the link error as the last line)...
linking failed: 'D:\FreeBASIC\bin\win32\ld.exe' terminated with exit code 1


I've searched the FB forums for the error.  The only thing I could find was in the linker's command line help (--allow-multiple-definition).  I've tried that option in the several places in WinFBE that allow adding compiler options (one place at a time) - but no change.

Any ideas on why the link error only shows up with WinFBE?  And what I can do to get rid of it?

Thanks!
Bruce






Paul Squires

Hi Bruce,

Thanks for trying out WinFBE. :)

The problem is that when you load files into a project, WinFBE will set them to certain file types by default. *.bas files get loaded as "Modules". Modules get compiled separately into object files. This is not what you need in this case. The pcg_advance.bas file is actually an "Include" file. You need to load that file into the editor and designate it as an "Normal" file (right click in the edit window and select the menu option, or click in the status bar). Once you do that, the errors will disappear.

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

I was going to post just the same. IMO it's a very bad habit to use .bas for everything. There is no way for the editor to know if it is the main program, a module or an include file, unless you tell it.

Paul Squires

Quote from: Jose Roca on December 02, 2017, 07:00:03 PM
I was going to post just the same. IMO it's a very bad habit to use .bas for everything. There is no way for the editor to know if it is the main program, a module or an include file, unless you tell it.

I agree. You and I have already had our say in the FB community regarding BAS files and module versus Includes.

For those lurking here (or ex-PowerBasic programmers), FB grew out of older school C language ideology where larger projects would have many BAS files with each of them being compiled into object (*.o) files. Those object files would then be linked to the main file to create your EXE. This was great in the old days when computers and compilers were somewhat slow because it saved you from having to recompile large chunks of your project all the time. WinFBE supports this type of programming but myself and Jose use the PB style whereby you #INCLUDE source files into the main source file and recompile every time. The actual WinFBE editor source code is structured this way and works perfectly, creating a more simplistic way to program your project.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Bruce Huber