Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: embed resource (icon, image, etc...) into compiled target. #1552

Closed
gopherbot opened this issue Feb 25, 2011 · 15 comments

Comments

@gopherbot
Copy link

commented Feb 25, 2011

by AllenGnr:

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. There is no way to embed resources into compiled target, so if I cannot give an
application icon to my windows GUI application created by Go.

What is the expected output?
1. Provide a tool or something to make it possible to embed resources into compiled
target.

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g


Which operating system are you using?
Windows 7


Which revision are you using?  (hg identify)
b2be017f9134 tip
@alexbrainman

This comment has been minimized.

Copy link
Member

commented Feb 25, 2011

Comment 1:

Labels changed: added os-windows.

Owner changed to @alexbrainman.

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 9, 2011

Comment 3:

Labels changed: added priority-later, removed priority-medium.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 12, 2011

Comment 4:

Labels changed: added priority-go1.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Jan 13, 2012

Comment 5:

Owner changed to builder@golang.org.

@gopherbot

This comment has been minimized.

Copy link
Author

commented Feb 28, 2012

Comment 6 by vcc.163:

8l: emit resources (.rsrc) in Windows PE.
http://code.google.com/p/go/source/detail?r=99a520c00dcf8231ee1ed8c69137e61b435663d6&path=/src/cmd/ld/ldpe.c
This issue should fixed.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2012

Comment 7:

Nice, thanks.  We still need a way to hook this up.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2012

Comment 8:

It looks like the ldpe support requires that the resource have been generated in a PE
object, meaning it was compiled from a C file during a build of a cgo package.  Is that
right?  Is that all we need?
@alexbrainman

This comment has been minimized.

Copy link
Member

commented Mar 7, 2012

Comment 9:

windres produce pe object file out of "resource" file (text file describing all its and
pieces). Then resulting object is linked to the final executable using 8l.exe.
Alex
@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2012

Comment 10:

does this work with the go tool? how?
@alexbrainman

This comment has been minimized.

Copy link
Member

commented Mar 7, 2012

Comment 11:

I do not think it would. Even if, lets say, you prebuild object file with resources (by
using windres in one way or the other), how would you ask go to peek that object file
and link it as part of an exe. Without make file it is.
Alex
@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2012

Comment 12:

We could say that if the .o file is sitting in the directory,
we add it to the archive, just as you used to do by
adding it to the OFILES list in the Makefile.
@alexbrainman

This comment has been minimized.

Copy link
Member

commented Mar 7, 2012

Comment 13:

I think, assuming that every .o file has to be part of an exe is a bit forceful. You
could go ahead with this idea. But with pe file, you could add sections after it is
built. So we can always creat tool that would add resources after. We could just use
make like before for these. We could write some sort of compiler that builds resources
out of source files. It is hard for me to see the use case until I actually do something
like that.
Alex
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2012

Comment 14:

But the GNU windres program is already a compiler that builds resources out of source
files.  Hard to see why we would need another one.  (Although when I wrote windres I
designed it so that it could generate various different output formats, and that still
seems to be true.)
This is another example of a tool like goyacc that generates an output file that should
be included in the program, although in this case the tool generates an object file
rather than Go source code.  If we have a reasonable way to handle generated files, it
should handle this case too.
In the meantime, gathering all .o files into the link sounds a bit error-prone to me,
but we could use a different extension--.ogo?--or we could list them in a //build
comment.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2012

Comment 15:

It would be nice if (1) the solution worked for clients of a package that needs a
resource without adding a new tool that all clients must have and (2) the solution was a
little more general than Windows resources.  I believe that it will work for both gccgo
and 6g if we can just get the object file into the package file, like we used to with
the Makefile OFILES list.
Perhaps .syso could be the extension for system object files that should be copied into
the package archive?
It is tempting (but unreasonable) to use .goo instead.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 8, 2012

Comment 16:

This issue was closed by revision b099633.

Status changed to Fixed.

@gopherbot gopherbot added fixed labels Mar 8, 2012

@rsc rsc added this to the Go1 milestone Apr 10, 2015

@rsc rsc removed the priority-go1 label Apr 10, 2015

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can’t perform that action at this time.