Windows DLL-linking with cgo - opengl

My ultimate goal is to successfully link to a number of DLLs (opengl32.dll glfw.dll and glu32.dll) from a Go package -- but trying to link to the go-glfw package gave me "not defined" errors.
So I decided to get a very simple cgo dynamic/shared library linking to work, from the simple unmodified example in %GOROOT%\misc\cgo\life. But just invoking the command go build -o life main.go fails with essentially the same linker error, namely:
go-build374967034/_/C_/Go/misc/cgo/life.a(c-life.o)(.text): _assert: not defined
"not defined"... just exactly the same error I had when trying to link glfw as per above.
This is a fresh untampered-with install of Go 1.0.1 freshly downloaded this morning, on a vanilla, fairly recent Win7 64-bit installation. What could possibly go wrong? I know... Windows. Would love to hear any ideas... seems like DLL linking with CGO is a no-brainer and simple to do from what I read around the net. Yet even the simplest of examples fails for me.

I've think this particular bug has been discussed here: http://code.google.com/p/go/issues/detail?id=3261
but I'm not sure if it can be applied to your case. In the end from what I've read they proposed a patching but not really tried 'cause I'm waiting 1.1 release (hoping they'll fix the runtime infamous memory leak ;) )

Related

OpenCV in Code::Blocks: The application was unable to start correctly (0xc00000be)

I set up OpenCV with Code::Blocks as per this tutorial: http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/.
I've got as far as building the test program at the end successfully, but when I try to run it I get the following error: "The application was unable to start correctly (0xc00000be). Click OK to close the application."
The one thing that is certainly different from the tutorial for me is that I'm working with OpenCV 3.0.0, Code::Blocks 13.12 and the latest version of mingw (number not obvious from their website or the installer).
I found that other people had had this problem in the past, e.g. The application was unable to start correctly (0xc00000be)
However, it has been a long time since that thread was active, I'm working with newer versions of the software and, most importantly, the answer given there didn't help (I compiled openCV with the same mingw that I'm using with Code::Blocks), so I thought this question would be worth asking (sorry if it's not, I'm rather new to this).
Could anybody suggest a fix that might get rid of this error?
A few other things to note:
I didn't download the Code::Blocks that came with mingw as I was advised against it, I got them separately as per the tutorial
I have installed OpenCV and Code::Blocks on my E: drive, though mingw is still on my C:.
I have added both mingw and OpenCV to my PATH variable, and mingw to my Path variable
I have linked the libraries in both the main compiler settings for Code::Blocks and the Build Options of my project.
I'm working from a 64-bit Windows 7 Laptop, but I have done everything 32-bit style as advised in the tutorial.
Thanks in advance!
So, one solution I've found to this problem is to copy all the .dll files from "...\opencv\build\x86\mingw\bin" to the project file (build directory).
Having done that, the project will run fine. This still doesn't (directly) explain why it wont run without those files (at least, several sources including the tutorial imply it should), and so isn't really optimal. I will continue to look for a solution for this so I don't have to clutter every opencv project I make with the .dlls.
However, for anyone simply wanting to get stuck into coding who is having this problem, I recommend that solution.

What can happen if I update code signature for SDL2?

I am a new user of macintosh and uses OS X 10.9.4 Mavericks. I have recently installed Xcode and I have downloaded SDL2. This is where the problems started.
When I tried to compile some code that uses SDL2, I got a Xcode crash. The crash was expected behaviors since the reason was an invalid code signature in SDL2.
So I googled this and 2 solutions came up in this link. The first solution recommended that I downloaded the source code for SDL2 and recompiled it. The second solution was to update the code signature as
codesign -f -s - ~/Library/Frameworks/SDL2.framework/SDL2
The second solution seems to be the preferred one since the first solution probably does this in the end anyway. However, I am not completely familiar with code signatures since I come from a windows environment (where these things are hidden for the most) and also since all programming I have done have been for internal use only. So this is the long introduction and my questions are then:
Where is the code signature located (inside the frameworks or somewhere else in the computer)?
What can happen if I update the code signature? Especially can this cause any trouble in the future and even if SDL2.framework is uninstalled?
BR Patrik
You are not required to code sign a framework you build and install yourself (this is what I do for SDL 2). When Frameworks are codesigned the signature can be found in the "Versions" subdirectory of the Framework bundle. there will be the usual _CodeSignature directory for each signed "version", just as there is for an "app" bundle.
resigning the framework wont affect anything in your system. when you update the SDL2 framework to a version that doesnt have this problem your changes will be "undone".

Setting up OpenCV with Windows 7 and Code Blocks

I have successfully built OpenCV and I have come to the point where code::blocks recognizes the OpenCV syntax and successfully builds the program. However when I run I get this error
"The procedure entry point_gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll."
I am using Code::Blocks v 12.11 and minGW (the most recent, I can't remember the version number) along with OpenCV-2.4.8 Has anyone ever seen this problem? Help if you can, anything right now might work since I am so close.
https://stackoverflow.com/questions/3895879/installing-opencv-on-windowsw32-to-be-used-with-code-blocks?rq=1
Using this link to the other question I was able to locate a hint for my problem. I had everything correct and the hint to change the build to a GUI Application solved the issue. The programs build and then run as they should.

MinGW GCC and G++ Errors in Eclipse

I'm new to this community and this is my first question. I know many people had had this problem before, but, it seems as if people solved it their own ways and I tried all the solutions I could find in google (and here, respectively), but none of them seem to work for me like it was supposed to. And just to make it clear, I use 32-bit Windows XP. Some versions that may work in 64-bit or newer operating systems may not work on mine.
So I'm very new to C and C++, I started by installing the Eclipse CDT, the moment I found out it did not have a compiler was when I installed MinGW which was bundled with a C compiler, a C++ compiler, and the MinGW Developer's Toolkit (which included MinSys). So after that, I started by creating a new empty C++ project called 'HyScript'. And did these:
I set the environment variables as:
C:\Program Files\Java\jre7\bin;E:\Mark\MinGW\msys\1.0\bin;E:\Mark\MinGW\bin
Then, I restarted eclipse, deleted the old projects, and created a new one with the same name (deleted the old folders) and chose the toolchair, "Cross GCC".
Now I haven't even started writing code, but there are already 4 errors:
Here's the link to the dropbox file
The last thing I did was open up the CMD before going here, and this happened: Here's another link to the dropbox file
I don't understand anymore... What did I do wrong? I set the environment variables right, I supposed. And, after doing some research, I still can't find a proper solution for me. It's been two days now, and this error still hasn't gone away.
You chose wrong toolchair "Cross GCC". Please select "MinGW"
The latest version of G++ can be found here. Please do NOT install it in the default directory but use this:
C:\MinGW
If you still have problems, uninstall everything you did, and watch these video instructions.

Anybody tried to compile Go on Windows?, It appears to now support generating PE Format binaries

http://code.google.com/r/hectorchu-go-windows/source/list
If you could compile it successfully, I like to know the procedures of how to.
Assuming you are using Hector's source tree:
Install MinGW and MSYS, along with MSYS Bison and any other tools you think you'll find useful (vim, etc).
Install ed from the GNUWin32 project.
Install Python and Mercurial.
Clone the [hectorchu-go-windows mercurial repository](https://hectorchu-go-windows.googlecode.com/hg/ hectorchu-go-windows) to C:\Go.
Run an MSYS shell (or rxvt). The rest of these are bash commands...
mkdir $HOME/bin
export PATH=$HOME/bin:$PATH
export GOROOT=C:\\Go
export GOARCH=386
export GOOS=mingw
cd /c/Go/src
./all.bash
Correct errors as it spits them out at you, repeat step 10 until it starts building.
It's the same idea as on Linux or MacOS, basically.
However, I still stand by what I said in my comment above: this isn't necessarily going to generate anything that actually works yet. You'd be better served by waiting until this effort has merged into the main Go tree before tackling it, unless your interest is in assisting with the porting effort.
Update: there is now a mostly-functional pre-built windows port available, for those not interested in building the compiler themselves. However, given the rate of change of the project, the lack of formal releases (other than the hg "release" tag), and the possibility of Hector's changes being merged into the main branch soon, keeping up with development via source builds is likely to produce better results over time.
Just FYI, there is seems official one now.
http://code.google.com/p/go-windows/
Hector said he was only able to get as far as being able to compile and run an empty main. See issue 107:
http://code.google.com/p/go/issues/detail?id=107
There is still a lot of work to do in porting that, especially since the code has lots of dependencies on ptrace and syscall, not to mention the different threading models between Linux/BSD and Windows.
Update:
There's a new thread on golang-nuts (started 26.03.2010) with a link to a recent build and some current building instructions (using MinGW+MSYS).