pure-gtk: Unable to build standalone executable

68 views
Skip to first unread message

a.c.k...@gmail.com

unread,
Mar 1, 2013, 3:59:34 PM3/1/13
to pure...@googlegroups.com
(Sorry if this is a dupe, but Google Groups seems to have eaten my previous post):

When I try to build pure-gtk's examples/hello.pure as a standalone executable, compilation fails with:

$ pure -v64 -o hello -c hello.pure
glib.pure, line 4574: symbol 'glib::linux' is already defined as a constant
glib.pure, line 4575: symbol 'glib::unix' is already defined as a constant
opt -f -std-compile-opts hello.bc | llc -o hello.s
gcc -c hello.s -o hello.o
g++ -o hello /usr/lib/pure/pure_main.o hello.o -Wl,--no-as-needed /usr/lib/pure/ffi.so /usr/lib/pure/gtk.so /usr/lib/pure/glib.so -L/usr/lib -lpure
/usr/bin/ld: hello.o: undefined reference to symbol 'gtk_window_set_default_size'
/usr/bin/ld: note: 'gtk_window_set_default_size' is defined in DSO /usr/lib/libgtk-x11-2.0.so.0 so try adding it to the linker command line
/usr/lib/libgtk-x11-2.0.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

Shouldn't Pure use the output of `pkg-config --libs gtk+-2.0` in the link command? When I do the individual build steps while substituting this, linking works:

$ pure -o hello.s -c hello.pure
$ gcc -c hello.s -o hello.o
$ g++ -o hello /usr/lib/pure/pure_main.o hello.o -Wl,--no-as-needed /usr/lib/pure/ffi.so /usr/lib/pure/gtk.so /usr/lib/pure/glib.so $(pkg-config --libs gtk+-2.0) -L/usr/lib -lpure

and the 'hello' executable runs without problems.
Should we perhaps store the output of 'pkg-config --libs glib+-2.0' inside glib.so, so Pure can use it when linking executables against pure-gtk's glib.so?

Bjoern Lindig

unread,
Mar 24, 2013, 7:02:27 AM3/24/13
to pure...@googlegroups.com
Hi,

I installed the gtk2-ubuntu package on archlinux, hoping this could
solve the problem. But it persists, still the same error. Is this as
archlinux only problem or can sb else reproduce it?

version:
Pure 0.57
LLVM 3.2
gtk2 2.24.16

Where in the buildprocess is the linker command executed? How could it
be influenced?

Maybe it is not very improtant, but I try to keep the packages on
archlinux clean. So if there is anything I can do, please let me know.
If not, I will remove this topic from my todo-list.

Best,

Bjoern

Alastair Pharo

unread,
Mar 26, 2013, 1:22:04 AM3/26/13
to pure...@googlegroups.com
Hi,

It seems that the example can can be compiled by adding the `--copy-dt-needed-entries` flag.  I get an executable that work if I replace your last command with the following (almost identical to what Pure normally produces):
  
    g++ -o hello /usr/lib/pure/pure_main.o hello.o -Wl,--no-as-needed,--copy-dt-needed-entries /usr/lib/pure/ffi.so /usr/lib/pure/gtk.so /usr/lib/pure/glib.so -L/usr/lib -lpure

If you take a look in the Makefile for pure-gtk, you will see that GTK_LIBS is already defined as `pkg-config --libs gtk+-2.0`, and that this is used for linking gtk.so in /usr/lib/pure (as `ldd /usr/lib/pure/gtk.so` should confirm).  I think that the extra flag is needed because the `g++` line above does not list the .so files using -l, but I'm not an expert on this sort of thing so I can't be sure.

I'm having a look to see if we can fix the arch install of pure to include this flag, and if so, whether this will work generally or not.

Cheers,

Alastair



2013/3/24 Bjoern Lindig <bjoern...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "pure-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pure-lang+...@googlegroups.com.
To post to this group, send email to pure...@googlegroups.com.
Visit this group at http://groups.google.com/group/pure-lang?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Albert Graef

unread,
Apr 29, 2013, 5:36:03 AM4/29/13
to pure...@googlegroups.com
On Tue, Mar 26, 2013 at 6:22 AM, Alastair Pharo <asp...@gmail.com> wrote:
It seems that the example can can be compiled by adding the `--copy-dt-needed-entries` flag.  I get an executable that work if I replace your last command with the following (almost identical to what Pure normally produces):
  
    g++ -o hello /usr/lib/pure/pure_main.o hello.o -Wl,--no-as-needed,--copy-dt-needed-entries /usr/lib/pure/ffi.so /usr/lib/pure/gtk.so /usr/lib/pure/glib.so -L/usr/lib -lpure

So what became of this issue? ack and Bjoern, did Alastair's suggestion resolve the issue for you?
 
On Fri, 1 Mar 2013 12:59:34 -0800 (PST)
a.c.k...@gmail.com wrote:

> Shouldn't Pure use the output of `pkg-config --libs gtk+-2.0` in the
> link command? When I do the individual build steps while substituting
> this, linking works:

Well, the batch compiler doesn't know the library dependencies of the Pure modules it links into the output program. The way the batch compiler handles this right now (adding the --no-as-needed option to the linkage command) used to work even with fairly recent gcc versions, but apparently not the latest ones any more. :( Anyway, if the solution is to add yet another quirky linker option, I can do that; I just need to make sure that the option is actually supported by the linker.

Albert
 
--
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email:  agg...@gmail.com
WWW:    http://www.musikinformatik.uni-mainz.de/ag

Alastair Pharo

unread,
Apr 30, 2013, 8:34:46 AM4/30/13
to Albert Graef, pure...@googlegroups.com
For the records, I've not done anything on this issue since suggesting
that flag. I was intending to try patching Pure to see if it fixed
compilation on Arch, but never got around to it ...

Albert Graef

unread,
May 3, 2013, 2:18:51 AM5/3/13
to Alastair Pharo, pure...@googlegroups.com
On Tue, Apr 30, 2013 at 2:34 PM, Alastair Pharo <asp...@gmail.com> wrote:
> For the records, I've not done anything on this issue since suggesting
> that flag. I was intending to try patching Pure to see if it fixed
> compilation on Arch, but never got around to it ...

Ok, no problem. I was rather looking for feedback from ack and Bjoern,
to see whether your suggestion resolved the issue. Anyway, if the
problem persists and there's something I need to change in the batch
compiler, please open a bug report.
Reply all
Reply to author
Forward
0 new messages