Page 1 of 1

Linker Error - What does it mean?

Posted: Sat Jul 09, 2011 6:36 am
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].

Re: Linker Error - What does it mean?

Posted: Sat Jul 09, 2011 3:57 pm
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)