Linker Error - What does it mean?

Mac OSX specific forum
coder14
Enthusiast
Enthusiast
Posts: 327
Joined: Tue Jun 21, 2011 10:39 am

Linker Error - What does it mean?

Post by coder14 »

Does anyone know why the following error occurs?

PureBasic - Linker Error
Undefined symbols:
"_CGRectMake" referenced from:
PSTub.CGRectMake in purebasic.o
Id: symbol(s) not found
collect2: Id returned 1 exit status.


FYI, [CGRectMake] is a Carbon function called with [ImportC].
User avatar
Shardik
Addict
Addict
Posts: 2076
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Linker Error - What does it mean?

Post by Shardik »

coder14 wrote:Does anyone know why the following error occurs?
In the example code of your posting Help with CGContext you forgot to declare
the return type CGRect for the API function CGRectMake().
PureBasic Help for Import wrote:Import "Filename"
FunctionName.<type>(<parameter>, [, <parameter> [= DefaultValue]...]) [As "SymbolName"]
...
VariableName.<type> [As "SymbolName"]
EndImport
Unfortunately even if you declare the return type correctly PureBasic will display
the following error:
PureBasic wrote:A structure can't be used with ProcedureReturn
because PureBasic can't return a structure from a function, so unfortunately it
is not possible to use this function... :?

This is a complete example which causes the above error message:

Code: Select all

Structure CGPoint
  X.F
  Y.F
EndStructure

Structure CGSize
  Width.F
  Height.F
EndStructure

Structure CGRect
  Origin.CGPoint
  Size.CGSize
EndStructure

ImportC ""
  CGRectMake.CGRect(X.F, Y.F, Width.F, Height.F) 
EndImport

*Rect.CGRect = CGRectMake(0.0, 0.0, 600.0, 600.0)

Debug "*Rect\Origin\X = " + Str(*Rect\Origin\X)
Post Reply