2mac
2mac

Reputation: 1689

C compiler errors during otherwise successful build

I made a library to link with a frontend I'm working on. The library isn't fully complete, but it's done enough to start testing what I've got.

Here is the only function in the frontend so far:

int main(string[] args)
{
    try
    {
        MCTH.init_lists();
        MCTH.init_names();
    } catch (FileError e) {
        stderr.printf("Error: %s\n", e.message);
    }

    // no errors
    return 0;
}

As far as I can tell, it's valid syntax for the library (the error and methods are defined in the vapi). However, when I go to build, I get errors in the C compiler:

valac src/main.vala -o bin/mctradehelp --pkg mctradehelp --pkg libxml-2.0
/tmp/ccdIz2Sn.o: In function `_vala_main':
main.vala.c:(.text+0x27): undefined reference to `mcth_init_lists'
main.vala.c:(.text+0x3f): undefined reference to `file_error_quark'
main.vala.c:(.text+0x11a): undefined reference to `mcth_init_names'
collect2: error: ld returned 1 exit status
error: cc exited with status 256

The vapi is located at /usr/share/vala/vapi, the header is in /usr/local/include, and the .so is in /usr/local/lib.

Am I passing the wrong flags, or is something not in the right place?

Upvotes: 1

Views: 112

Answers (1)

apmasell
apmasell

Reputation: 7153

Vala passes compile and link arguments to the C compiler for each package by using the matching pkg-config data (/usr/local/lib/pkgconfig/mctradehelp.pc in this case). If that file doesn't exist, then it won't pass any args. You can pass them manually using -X -lmctradehelp.

Upvotes: 2

Related Questions