0

I am trying to use static libraries that are written in c in an iOS Project. I included the .lib files and the .h into the iOS project. When I try to import the header files in one of my objective-C classes I get a lot of Expected '=',',',';','asm' or 'attribute' before... errors in the .h file of my static library.

I am using xCode4 for Development which seems to have added the libs correctly. When I open the project with Xcode 3 the libs are added to the Target Group "link binary with libraries" as stated in How to resolve linking error - static lib iPhone.

I got the static libs from a company that actually uses these libraries so I guess the header file is not at fault. I could not find any errors myself.

Is there a way to use .lib files with correct header files in an ios project? Or do I have to do anything besides adding the lib files to the target group in order to use them in my project?

Best Regards, Mike

edit

the actual error message:

Expected * before * Expected '=',',',';','asm' or 'attribute' before _far _pascal

The actual code where the header is imported:

#import <Foundation/Foundation.h>
#import "SomethingDll.h"


@interface AccountingEntry : NSObject {
    NSString *entryDescription;
    NSDate *entryDate;
    double entryAmount;
    NSString *entryType;

}

@property (nonatomic, retain) NSString *entryDescription;
@property (nonatomic, retain) NSDate *entryDate;
@property (nonatomic) double entryAmount;
@property (nonatomic, retain) NSString *entryType;

//class methods go here

//instance methods go here
-(id)initWithDescription:(NSString *)eDesc date:(NSDate*)eDate amount:(double)eAmount type:(NSString *)eType;


@end

The .h file of the lib.

#ifndef __SOMETHING_DLL
#define __SOMETHING_DLL



// constants for a function

#define FIRST_ERRTEXT    0
#define NEXT_ERRTEXT    1         

/*
...
some other #define of constants

*/ 

// Callback-Pointer Definitionen 

#define INFO_FUNC_DECL            BOOL (CALLBACK *lpInfoFunc)(int)
#define FILETRANS_FUNC_DECL     void (CALLBACK *lpFileTransFunc)(int,long)


// Funktionsdeklarationen

#ifdef WIN32
#define IMPORTAPI WINAPI
#else
#define IMPORTAPI  _far _pascal 
#endif


#ifdef __cplusplus
extern "C" {
#endif

    void  IMPORTAPI Something_Config(         int  iLogLevel,                   char *szLogFile,      
                                 long lTimeOut_Connect,           long lTimeOut,   
                                 long lTimeout_GetFile,           long lTime_Info,
                                 int  iSSLVersion,               char *szSSLCipher,
                                 char *szVerifyCertificateFile, char *szVerifyCertificatePath);
/*
  ...
  a lot of other functions
  ...
*/
#ifdef __cplusplus
}
#endif                      

#endif // End
3
  • Some actual error messages might make it easier to diagnose the problem. Nov 10, 2010 at 10:57
  • Or some actual code where header files are imported
    – Eimantas
    Nov 10, 2010 at 11:02
  • I added the actual code, the error message and the .h file of the lib. Thank you. Nov 10, 2010 at 11:23

1 Answer 1

1

It seams that this lib is for Win32, the _far _pascal directive is not available on gcc and the other errors may come from missing definitions. Maybe you have to look for another lib to do the job.

2
  • does this mean that the whole library is unusable on IOS? I am not really familiar with c. what does __far _pascal do? Nov 10, 2010 at 12:09
  • It's seams to... There is a lot of lib's for iOS, surely you can find one to do the job. '_far _pascal' = "The "_far _pascal" modifiers use the normal DLL parameter passing convention, which specifies DLLs are in a separate segment ("_far") and that the "_pascal" parameter passing system is used, which is that parameters are passed left to right and that the called function cleans up the stack" (ubercode.com/learning-to-write-programs-in-c.html) Nov 10, 2010 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.