My project contains both C and Objective-C source code, and I am going to generate makefile using cmake.
Basically it was built in MacOS, but now it's going to be used in ubuntu.
So I have installed necessary packages for Objective-C and just added both *.m and *.c files together into the config, but it isn't compiled.
Following is the error message.
In file included from /usr/include/GNUstep/Foundation/NSObject.h:30,
from /usr/include/GNUstep/Foundation/FoundationErrors.h:29,
from /usr/include/GNUstep/Foundation/Foundation.h:33,
from /home/khan/Documents/work/tun2socks-iOS/base/BLog.m:32:
/usr/include/GNUstep/Foundation/NSObjCRuntime.h:230:16: warning: redundant redeclaration of ‘NSSelectorFromString’ [-Wredundant-decls]
230 | GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/GNUstep/Foundation/NSObjCRuntime.h:228:16: note: previous declaration of ‘NSSelectorFromString’ was here
228 | GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
| ^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/GNUstep/Foundation/NSDebug.h:39,
from /usr/include/GNUstep/Foundation/Foundation.h:36,
from /home/khan/Documents/work/tun2socks-iOS/base/BLog.m:32:
/usr/include/GNUstep/GNUstepBase/NSDebug+GNUstepBase.h:45:16: warning: redundant redeclaration of ‘GSDebugSet’ [-Wredundant-decls]
45 | GS_EXPORT BOOL GSDebugSet(NSString *level);
| ^~~~~~~~~~
In file included from /usr/include/GNUstep/GNUstepBase/NSDebug+GNUstepBase.h:36,
from /usr/include/GNUstep/Foundation/NSDebug.h:39,
from /usr/include/GNUstep/Foundation/Foundation.h:36,
from /home/khan/Documents/work/tun2socks-iOS/base/BLog.m:32:
/usr/include/GNUstep/Foundation/NSProcessInfo.h:287:16: note: previous declaration of ‘GSDebugSet’ was here
287 | GS_EXPORT BOOL GSDebugSet(NSString *level);
| ^~~~~~~~~~
/home/khan/Documents/work/tun2socks-iOS/base/BLog.m: In function ‘stdout_log’:
/home/khan/Documents/work/tun2socks-iOS/base/BLog.m:55:5: error: cannot find interface declaration for ‘NXConstantString’
55 | NSLog(@"%s(%s): %s\n", level_names[level], blog_global.channels[channel].name, msg);
| ^~~~~
make[2]: *** [base/CMakeFiles/base.dir/build.make:76: base/CMakeFiles/base.dir/BLog.m.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:283: base/CMakeFiles/base.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
And this is my subdirectory's CMakeList.txt.
set(BASE_ADDITIONAL_SOURCES)
if (HAVE_SYSLOG_H)
list(APPEND BASE_ADDITIONAL_SOURCES BLog_syslog.c)
endif ()
set(BASE_SOURCES
DebugObject.c
BLog.m
BPending.c
${BASE_ADDITIONAL_SOURCES}
)
badvpn_add_library(base "" "" "${BASE_SOURCES}")
The main problem here is that the project contains both Objective-C and C files. I know when only Objective-C is used, the additional flag gnustep-config --objc-flags
must be specified, but not sure how I can handle this when 2 different language source codes are mixed.
Sorry for my bad English, and thanks in advance to your advice.