Page 1 of 1
ImportC PureBasic - Linker error
Posted: Wed Jul 08, 2015 12:40 pm
by Wolfram
Hello everybody!
I get an Linker error when importing a C file on PB 5.31 64 and 32 bit on OSX 10.9.4.
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
clang: error: cannot specify -o when generating multiple output files
These works on 10.7
Code: Select all
ImportC "/usr/include/sys/unistd.h"
usleep(T)
EndImport
and these not on 10.9
Code: Select all
ImportC "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/unistd.h"
usleep(T)
EndImport
Whats wrong???
Re: ImportC PureBasic - Linker error
Posted: Wed Jul 08, 2015 4:05 pm
by Trond
None of these are supposed to work!
Import and ImportC are for importing compiled symbols from object files (
compiled files).
Import
C only refers to the calling convention used. It doesn't import C source files.
If the command you wish to import is part of the standard libraries that are already linked, you do not have to specify a filename. So you can do:
Else you must put the filename of an object file.
Re: ImportC PureBasic - Linker error
Posted: Thu Jul 09, 2015 7:03 pm
by Shardik
Trond is right! You should use just ImportC ""... EndImport.
usleep(Microseconds.i) is a BSD command (MacOS X is just a modified BSD Unix with a mach kernel, the basic OS parts of MacOS without any GUI are open sourced by Apple and called Darwin) to suspend execution of your program for the specified microseconds. You might as well use sleep(Seconds.i) to wait the specified time in seconds or nanosleep(Nanoseconds.i) to wait the specified nanoseconds. To obtain help for these commands you may open a shell and type
> man usleep
You may even try these commands in the shell:
> sleep 2
This is an example program which I tested on Mavericks (OS X 10.9.5) and which should just work on all MacOS X versions:
Code: Select all
ImportC ""
sleep(Seconds.I) ; Suspend execution for the given number of seconds
usleep(Microseconds.I) ; Suspend execution for the given number of microseconds
nanosleep(Nanoseconds.I) ; Suspend execution for the given number of nanoseconds
EndImport
Debug "Starting to wait for 2 seconds..."
sleep(2)
Debug "2 seconds have expired!"
Debug ""
Debug "Starting to wait for 1500000 microseconds..."
usleep(1500000)
Debug "1500000 microseconds (= 1.5 second) have expired!"
Why do you have to use sleep() at all? I assume that PureBasic's native Delay(Milliseconds.i) command is just a wrapper of usleep() or nanosleep()...

Re: ImportC PureBasic - Linker error
Posted: Thu Jul 09, 2015 10:06 pm
by Wolfram
Thanks Trond, Thanks Shardik.
…sometimes the problem is in front of the computer
Why do you have to use sleep() at all? I assume that PureBasic's native Delay(Milliseconds.i) command is just a wrapper of usleep() or nanosleep()
Because I need 0.1 ms delay.