Loading libSystem.dylib on Mac OS X?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Loading libSystem.dylib on Mac OS X?

Joachim Geidel
I am currently testing a new version of JNIPort on Mac OS X 10.6, and there
is a problem in VisualWorks 7.5. JNIPort needs some functions from the
standard C library, and there is an ExternalInterface for that which uses
libSystem.dylib. In VW 7.7 and 7.7.1, everything works as intended. In VW
7.5 however, I can't load the library. #primLoadLibrary results in a
primitive failure for the ExternalLibrary with name #'libSystem.dylib':

a SystemError(#'generic error','NSObjectFileImageInappropriateFile')

This does not happen in VW 7.7. Does anybody know what could be wrong?

Thanks in advance for any help!
Joachim Geidel

-------

The class is defined as follows (you'll have to remove the Namespace JNIPort
if you want to try the code):

Smalltalk.JNIPort defineClass: #StandardLibInterface
    superclass: #{External.ExternalInterface}
    indexedType: #none
    private: false
    instanceVariableNames: ''
    classInstanceVariableNames: ''
    imports: '
            private JNIPort.StandardLibInterfaceDictionary.*
            '
    category: 'JNIPort StandardLibInterface'
    attributes: #(
            #(#includeFiles #('stdio.h' 'stdarg.h'))
            #(#includeDirectories #('include'))
            #(#libraryFiles #('msvcrt.dll' 'libc.so.6' 'libc.sl'
'libSystem.dylib'))
            #(#libraryDirectories #())
            #(#beVirtual false)
            #(#optimizationLevel #full))

To reproduce, you'll need the following methods:

StandardLibInterface class>>libraryFilesSearchSignals

    ^LibraryNotFoundError, LibraryNotLoadedError,
ExternalObjectNotFoundError

StandardLibInterface>>primGetenv: string
    "Answer the value of the environment variable aString."

    <C: char * getenv( const char *string )>
    ^self externalAccessFailedWith: _errorCode

Code to reproduce the error:

StandardLibInterface new primGetenv: 'HOME'


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Loading libSystem.dylib on Mac OS X?

Michael Lucas-Smith-2

On Jan 18, 2011, at 11:23 PM, Joachim Geidel wrote:

> I am currently testing a new version of JNIPort on Mac OS X 10.6, and there
> is a problem in VisualWorks 7.5. JNIPort needs some functions from the
> standard C library, and there is an ExternalInterface for that which uses
> libSystem.dylib. In VW 7.7 and 7.7.1, everything works as intended. In VW
> 7.5 however, I can't load the library. #primLoadLibrary results in a
> primitive failure for the ExternalLibrary with name #'libSystem.dylib':
>
> a SystemError(#'generic error','NSObjectFileImageInappropriateFile')
>
> This does not happen in VW 7.7. Does anybody know what could be wrong?

It's possible the 7.5 VM was compiled with OSX 10.4 and cannot load the dylib you've specified. Try using a newer vm with the older image?

Michael
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Loading libSystem.dylib on Mac OS X?

Joachim Geidel
Am 19.01.11 09:23 schrieb Michael Lucas-Smith:

>> I am currently testing a new version of JNIPort on Mac OS X 10.6, and there
>> is a problem in VisualWorks 7.5. JNIPort needs some functions from the
>> standard C library, and there is an ExternalInterface for that which uses
>> libSystem.dylib. In VW 7.7 and 7.7.1, everything works as intended. In VW
>> 7.5 however, I can't load the library. #primLoadLibrary results in a
>> primitive failure for the ExternalLibrary with name #'libSystem.dylib':
>>
>> a SystemError(#'generic error','NSObjectFileImageInappropriateFile')
>>
>> This does not happen in VW 7.7. Does anybody know what could be wrong?
>
> It's possible the 7.5 VM was compiled with OSX 10.4 and cannot load the dylib
> you've specified. Try using a newer vm with the older image?

That seems to be it. When I use the VW 7.5 or 7.6 VMs, the library can't be
loaded, with the 7.7 VM everything works.

Thanks!
Joachim


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc