Problem building shared library with Gcc 8

General FreeBASIC programming questions.
paul doe
Posts: 984
Joined: Jul 25, 2017 17:22
Location: Argentina

Problem building shared library with Gcc 8

Postby paul doe » Nov 11, 2019 21:22

Testing the new 1.07.1 release, I came to the following issue, using the Gcc 8 toolchain:

Code: Select all

function _
  createComponent alias "createComponent"( _
    byref aComponentName as const string ) _
    as any ptr export
   
    ? "Component " & aComponentName & " created."
   
    return( 0 )
end function

Compiling the above yields this lovely result:

C:\Programming\Freebasic\FreeBASIC-1.07.1-win64-gcc-8\fbc -s console -dll -export -gen gcc -Wc -Ofast "gcc-8-dll-bug-dll.bas"
Warning: .drectve `Hƒút' unrecognized
Warning: .drectve `¸' unrecognized
Warning: .drectve `Ã' unrecognized
Warning: .drectve `Hƒì(E1À1Ò1Éè' unrecognized
Warning: .drectve `¸' unrecognized
Warning: .drectve `HƒÄ(Ã' unrecognized

Make done


Do note that the lib is indeed compiled. Trying to use it, however, is futile:

Code: Select all

var _
  aLib => dyLibLoad( "gcc-8-dll-bug-dll" )

if( aLib = 0 ) then
  ? "Failed to load lib."
end if

dim as function( _
  byref as const string ) _
  as any ptr _
  createComponent => dyLibSymbol( aLib, "createComponent" )

if( createComponent = 0 ) then
  ? "Could not find symbol"
else
  createComponent( "MyComponent" )
end if

sleep()

Anyone encountered this before? Is this reported somewhere?

The same code, with old trusty 5.2 doesn't give any troubles. Hadn't tested the Gcc 7 toolchain yet.
srvaldez
Posts: 2160
Joined: Sep 25, 2005 21:54

Re: Problem building shared library with Gcc 8

Postby srvaldez » Nov 11, 2019 22:35

hello paul doe
I just downloaded FreeBASIC-1.07.1-win64-gcc-8.1.0 and compiling your example gives the error you describe.

I had similar experiences before viewtopic.php?f=3&t=26973&p=251109&hilit=Warning%3A+.drectve#p251109
paul doe
Posts: 984
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Problem building shared library with Gcc 8

Postby paul doe » Nov 12, 2019 21:01

srvaldez wrote:hello paul doe
I just downloaded FreeBASIC-1.07.1-win64-gcc-8.1.0 and compiling your example gives the error you describe.

I had similar experiences before viewtopic.php?f=3&t=26973&p=251109&hilit=Warning%3A+.drectve#p251109

Hey, srvaldez. Thanks for the link, going to read it now. It is the only issue I encountered so far with the Gcc 8 toolchain. Removing the export clause compiles fine, but there's no point to it...

[After reading the link] I'm using the official build that Jeff released in the 'News' topic, as is (no custom tools). Mmm...
paul doe
Posts: 984
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Problem building shared library with Gcc 8

Postby paul doe » Nov 13, 2019 20:47

Update: seems like compiling libs with optimizations is what's causing the problems in the Gcc 8 toolchain. As reported by srvaldez, neither the 5.x and the 6.x branches give any troubles. Didn't tested the 7.x yet.

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest