On Linux, using Gradle, I’m trying to build a C static library using the C plugin. It fails with compiler error messages. But I can build the static library successfully using an existing batch/make file. I assume I need to add compiler flags to my build.gradle, but I don’t know how, and can’t find documentation for it.
Here’s a summary of my problem:
On Linux, when I use Gradle to build a static library, I get compiler errors
concerning C-style “far” pointers. But if I build using well-developed batch/make
files, it compiles and links successfully.
Let’s say my project directory is /home/me/mylib
In that library, I have gradle.build that looks like this:
apply plugin: ‘c’
model {
components {
mylib(NativeLibrarySpec) {
sources {
c {
source {
srcDirs "src"
include "*.c"
}
exportedHeaders {
srcDir "inc"
}
}
}
}
}
}
I type:
./gradlew build
I get error messages, all involving *far pointers. A typical bad line
looks like this:
int far *pSomething;
with an error message in output.txt like this:
myHdr.h:21: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
There’s an options.txt file, apparently generated automatically,
which looks like this:
-x
c
-c
-I
/home/me/mylib/inc
-isystem
/usr/local/include
-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include
-isystem
/usr/include
-m64
If I try to use the good-old batch file, it works, with this message:
/usr/bin/gcc -I. -I/home/me/mylib/inc -DUNIX -DRS6000
-DIBMRS6000 -DNDEBUG -c -fPIC -m64 -dalign -DDS_64BIT -O0
-o /home/me/mylib/obj/myfile.o
-c /home/me/mylib/src/myfile.c
I assume that this successful compile line tells me what options I need
to use, and I should encorporate these options into my gradle.build. But
I have no idea which of these options need to be inserted. (Maybe all?)
And I have no idea what syntax to use in gradle.build to put in these
options.
Any help would be appreciated!