Static linking

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Static linking

Post by jj2007 »

What's wrong here? Why do I get "error: undefined reference to `MBRAND@8'"? With C, the library works fine...

Code: Select all

#Include "PCG32II.bas"
#inclib "MbRand"		' MbRand.a is a Windows *.lib file

Dim As pcg32 pcg
Dim As ULong i
Print "Rand"
For i = 1 To 6
  Print pcg.rand
Next

Print "Rand"
For i = 1 To 6
  Print pcg.rand
Next

Declare Function MbRand(byval bytes as Integer, byval seed As Integer) As Long Ptr
' error: undefined reference to `MBRAND@8'
Dim MyNumbers as Long ptr=MbRand(1000, 0)

Sleep
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Static linking

Post by srvaldez »

hi jj2007
try extern "Windows" or extern "Windows-MS" (or Extern "C" if it's calling convention is cdecl) in your declare, example

Code: Select all

Extern "Windows"
	Declare Function MbRand(byval bytes as Integer, byval seed As Integer) As Long Ptr
End Extern
when using extern the symbol case is preserved so it's not up-cased like MBRAND@8
Post Reply