Why does my cross-compiling fail?

hlefebvr

I'm new to Linux programming and I'm trying to compile a c file including the GTK+ library. My file is called test.c and it's supposed to run on Windows computers. I'm using the command:

i586-mingw32msvc-gcc `pkg-config --cflags gtk+-3.0` -o test test.c `pkg-config --libs gtk+-3.0`

I get an awful error, I tried to figure out what went wrong by myself but didn't manage to understand what's going on here.

This is the output: compiler output

mr.spuratic

You're almost certainly running pkg-config with the host metadata files, such output will likely make your cross-compiler, erm, cross.

Try this tutorial, it explains how to do what you want starting with downloading the required GTK+-3.0 win32 binaries, and setting up your linux environment so that pkg-config picks up the target metadata files:

http://www.tarnyko.net/en/?q=node/45

The job of pkg-config is to provide a straightforward way for one program to determine the compiler and linker requirements, and any dependent libraries for a library it uses. It also makes it easier for autoconf (and the user) to determine the presence, version and dependencies of specific packages. Your examples are using:

pkg-config --cflags gtk+-3.0
pkg-config --libs gtk+-3.0

Those will output the compiler and library flags that a program using gtk+-3.0 needs. Assuming you have a native version installed on your system, the default output will be suitable only for your type of system (paths, library names, dependent libraries etc).

The trick with cross-compiling is to have a separate tree of source, .pc (pkg-config meta-data), libraries and header files (for each targeted architecture). When you run pkg-config during configure/compile, you can set PKG_CONFIG_PATH as in the tutorial above so it picks up the correct .pc files for the targeted architecture.

There's a little bear trap here though: PKG_CONFIG_PATH adds to the start of the search path, so it can still fall back to the wrong package details if you have not installed the required software into your target tree, but you have a "native" version installed. You should usually set PKG_CONFIG_LIBDIR instead, this replaces the default path (typically /usr/lib/pkgconfig). That way when you cross-compile something more elaborate that uses autoconf (configure scripts) you (hopefully) get a sensible diagnostic about missing packages, rather than having the wheels come off mid-way through the compile.

For example, I can use this to list just the OpenWRT MIPS packages I have in one cross-compile tree:

WRTROOT=/openwrt/staging_dir/target-mips_r2_uClibc-0.9.32/
PKG_CONFIG_PATH=  PKG_CONFIG_LIBDIR=${WRTROOT}/usr/lib/pkgconfig pkg-config --list-all

Unsetting PKG_CONFIG_PATH prevents it finding extra packages in my /usr/local, setting PKG_CONFIG_LIBDIR means it won't find the native system ones.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why does my NSMutableURLRequest fail?

From Java

Why does assembly binding fail in my project?

From Dev

Why does my redirected CORS request fail?

From Dev

Why does my rspec test fail?

From Dev

Why does my kernel fail to build?

From Dev

Why does my linq to sql query fail?

From Dev

Why does my pointer arithmetic fail in this array

From Dev

Why does my wifi fail to stay connected?

From Dev

Why does my jasmine tests fail on this directive?

From Dev

Why does my Vapor query always fail?

From Dev

Why Does My FAMILY Query Fail?

From Dev

Why does my AMD CPU have trouble compiling applications?

From Dev

Why does my python script break after compiling?

From Dev

Why does compiling Spark application from within sbt session fail with "object apache is not a member of package org"?

From Dev

Why does my HUnit test suite fail but pass successfully in Cabal?

From Dev

Why does cron silently fail to run sudo stuff in my script?

From Dev

Why does my WebSockets handshake fail with ERR_CONNECTION_RESET?

From Dev

Why does my Python script fail with syntax errors?

From Dev

Why does my shell command with nested backticks fail?

From Dev

Why does my code run without 'Option Explicit' but fail with it?

From Dev

Why does my LDAP redirect script fail with one user?

From Dev

why does my javascript code for changing(onclick) the div opacity fail?

From Dev

Python: Why does my 'less than' test fail?

From Dev

Why does `:Wq` in VIM cause my commit to fail later?

From Dev

Why does my ARM template, fail to create authorization rules consistently?

From Dev

Why does my regular expression ALWAYS fail in Go?

From Dev

Why Does My Web API Fail On Put Only?

From Dev

Why does my menu with select fail the first time?

From Dev

Why does my Github secret fail (change on each event)?

Related Related

  1. 1

    Why does my NSMutableURLRequest fail?

  2. 2

    Why does assembly binding fail in my project?

  3. 3

    Why does my redirected CORS request fail?

  4. 4

    Why does my rspec test fail?

  5. 5

    Why does my kernel fail to build?

  6. 6

    Why does my linq to sql query fail?

  7. 7

    Why does my pointer arithmetic fail in this array

  8. 8

    Why does my wifi fail to stay connected?

  9. 9

    Why does my jasmine tests fail on this directive?

  10. 10

    Why does my Vapor query always fail?

  11. 11

    Why Does My FAMILY Query Fail?

  12. 12

    Why does my AMD CPU have trouble compiling applications?

  13. 13

    Why does my python script break after compiling?

  14. 14

    Why does compiling Spark application from within sbt session fail with "object apache is not a member of package org"?

  15. 15

    Why does my HUnit test suite fail but pass successfully in Cabal?

  16. 16

    Why does cron silently fail to run sudo stuff in my script?

  17. 17

    Why does my WebSockets handshake fail with ERR_CONNECTION_RESET?

  18. 18

    Why does my Python script fail with syntax errors?

  19. 19

    Why does my shell command with nested backticks fail?

  20. 20

    Why does my code run without 'Option Explicit' but fail with it?

  21. 21

    Why does my LDAP redirect script fail with one user?

  22. 22

    why does my javascript code for changing(onclick) the div opacity fail?

  23. 23

    Python: Why does my 'less than' test fail?

  24. 24

    Why does `:Wq` in VIM cause my commit to fail later?

  25. 25

    Why does my ARM template, fail to create authorization rules consistently?

  26. 26

    Why does my regular expression ALWAYS fail in Go?

  27. 27

    Why Does My Web API Fail On Put Only?

  28. 28

    Why does my menu with select fail the first time?

  29. 29

    Why does my Github secret fail (change on each event)?

HotTag

Archive