compile gopacket on windows 64bit - go

I am trying to use gopacket on my windows 10.
I'm using it to sniff and inject packets directly to/from the NIC.
I can easily compile and run my code with GOARCH=386 but can't in GOARCH=amd64.
Worth noticing: I am NOT trying to cross-compile.
I'm using go1.6.windows-386 to compile the 32bit version and when I try to compile with GOARCH=amd64 I use go1.6.windows-amd64.
I used TDM-GCC as linux like compile tools.
The error isn't indicative. it just says
c:/WpdPack/Lib/x64/wpcap.lib: error adding symbols: File in wrong format
collect2.exe: error ld returned 1 exit status
Did anyone manage to build this, if it's even possible?

OK so I have figured it out.
In order to compile gopacket 64bit on windows you need to do the following:
Install go_amd64 (add go binaries to your PATH)
Install TDM GCC x64 (add TDM-GCC binaries to your PATH)
Also add TDM-GCC\x86_64-w64-mingw32\bin to your PATH
Install Winpcap
Download Winpcap developer's pack and extract it to C:\
Now the point is that there are missing linux static libraries files
(libwpcap.a and libpacket.a) from lib/x64 folder. I don't know why they weren't
included in the developers pack but anyway that's how we can generate them:
find wpcap.dll and packet.dll in your PC (typically in c:\windows\system32
copy them to some other temp folder or else you'll have to supply Admin privs to the following commands
run gendef on those files gendef wpcap.dll and gendef packet.dll (obtainable with MinGW Installation Manager, package mingw32-gendef)
this will generate .def files
Now we'll generate the static libraries files:
run dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libwpcap.a --input-def wpcap.def
and dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libpacket.a --input-def packet.def
Now just copy both libwpcap.a and libpacket.a to c:\WpdPack\Lib\x64
That's it.
Now gopacket should compile with no problems.

Thank you so much for the solution, it saved me a lot of time!
Just wanted to add that you can do the same with Npcap, modify the gopacket source code to point to Npcap and it will work too.
In case you don't know Npcap:
https://nmap.org/npcap/vs-winpcap.html
https://nmap.org/npcap/

I installed Npcap on Windows in "Wpcap API Compatibility Mode" and gopacket now works fine.

Related

Allegro 5 and FreeBASIC

I cannot find a way to make Allegro5 work with FreeBasic on Windows.
I downloaded and installed FreeBASIC-1.05.0-win32.exe.
I downloaded Allegro binaries allegro-5.0.10-mingw-4.7.0.
The version of fbc installed is the standalone one.
I created allegrolibs folder and copied these libraries from the Allegro distribution to allegrolibs:
liballegro_5.0.10-md.a
liballegro_font-5.0.10-md.a
liballegro_ttf-5.0.10-md.a
I added the necessary allegro dlls from the Allegro distribution to examples/graphics/allegro:
allegro_font-5.0.10-md.dll
allegro_ttf-5.0.10-md.dll
allegro-5.0.10-md.dll
I run fbc from the command line, trying to compile hello.bas from examples/graphics/allegro5:
fbc -s gui -p allegrolibs examples/graphics/allegro5/hello.bas
The program compiled just fine.
However, at runtime hello.exe shows me this error:
The program can't start because libgcc_s_dw2_1.dll is missing from your computer.
Copy libgcc_s_dw2_1.dll from FreeBASIC\bin\win32 to the folder where hello.exe resides, then run:
The program can't start because libstdc++-6.dll is missing from your computer.
Add libstdc++-6.dll from a ming4.7.0 binary distribution then run:
The program can't start because libgcc_s_sjlj-1.dll is missing from your computer.
Add libgcc_s_sjlj-1.dll from ming4.7.0 binary distribution then run:
The program can't start because libwinpthread-1.dll is missing from your computer.
Add libwinpthread-1.dll from ming4.7.0 binary distribution then run:
The procedure entry point __gxx_personality_v0 could not be located
in the dynamic link library libstd++-6.dll.
At this point I'm stuck. What is it that I'm doing wrong? Anybody who tried the same and was able to solved it is willing to help with the issue?
allegro-5.0.10-mingw-4.7.0 binary for Windows was compiled with mingw-4.7.0 compiler.
freeBASIC was compiled with a mingw-w64 compiler.
But as far as dynamic linking, they can work together.
The binary package for Windows allegro-5.0.10-mingw-4.7.0 contains among many other things two files:
allegro-5.0.10-monolith-mt.dll
liballegro-5.0.10-monolith-mt.a
Either of them can be used to link Allegro 5 library to the exe:
Copy allegro-5.0.10-monolith-mt.dll or liballegro-5.0.10-monolith-mt.a in allegrolib folder.
Modify allegro.bi, allegro_font.bi, allegro_ttf.bi replacing line 35 with:
#inclib "allegro-5.0.10-monolith-mt"
Run from the console:
fbc -s gui -p allegrolib examples/graphics/allegro5/hello.bas
allegro-5.0.10-monolith-mt.dll needs to be placed in the same folder with hello.exe.

Gstreamer on windows

I'd like to build application using Gstreamer 1.0 and GTK+-3.0 on Windows 8 (64bit).
I have sucessfully install and build GTK+-3.0, 32 bit version using Dev-C++ and Mingw 32-bit (there is no 64 bit version of GTK+). Everything works perferkt. It also installed pkg-config, I addeded it in %PATH% and it works.
I have installed gstreamer-1.0-devel-x86-1.4.4.msi and gstreamer-1.0-x86-1.4.4.msi from here
1) First problem: it installed itself into I:\gstreamer\ without asking me. I am very unhappy about it, I'd like have it on C:. But its not the biggest problem.
2) pkg-config do not know about gstreamer. I have found in I:\gstreamer\1.0\x86\lib\pkgconfig\ *.pc files, so I looked into gstreamer-1.0.pc and added to my projekt this options:
C compiler:
-I"I:/gstreamer/1.0/x86/include/gstreamer-1.0/"
Linker:
-L"I:/gstreamer/1.0/x86/lib" -lgstreamer-1.0
3) Now the program was compiled, but when I run it, it was not able to find gstreamer-1.0-0.dll. So i tried copy I:\gstreamer\1.0\x86\bin\gstreamer-1.0-0.dll into to the same directory as is my compiled file. Then it was not able to find libwinptread-1.dll. So I copied it also.
Then te program run, but it faild with some error like "cannot find entry point to windows thread ..." (I do not remember it exactly). So I copied ALL dll files from I:\gstreamer\1.0\x86\bin\ and then finally the program run.
But now it is not able to create elements:
source = gst_element_factory_make ("videotestsrc", "source");
//source is null
So, my question is, how to install gstreamer, that my program will find all dll files and will be able to create elements?
installing -- choose "custom install", there you can change the installation path.
for vs you can use *.props (gstreamer\1.0\x86\share\vs\2010\libs)
you need set Environment variable - GST_PLUGIN_SYSTEM_PATH_1_0 to plug-ins. For more details see http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gst-running.html

Is it possible to set up GStreamer for use in MinGW, similar to how it's done in Linux?

Apologies for the tardy title, I'm not quite sure how to phrase this question. At its most basic, I'm attempting to compile a program with GStreamer. When running the configure script for said program I get the following error:
0:20.39 configure: checking for gstreamer-1.0 >= 1.0
0:20.39 gstreamer-app-1.0
0:20.39 gstreamer-plugins-base-1.0
0:20.39 configure: error: gstreamer and gstreamer-plugins-base development pack
ages are needed to build gstreamer backend. Install them or disable gstreamer su
pport with --disable-gstreamer
The build environment I'm compiling in:
Windows 7 (64-Bit)
MINGW & MSYS
Visual C/C++ 2010 SP1 (command line)
Now if this error occurred on a Linux distro, - say Ubuntu - it could be remedied by running the following commands:
apt-get install libgstreamer-plugins-base1.0-dev
apt-get install libgstreamer1.0-dev
What is the equivalent for Windows? I've found two type of versions that can be used: The gstreamer bin from the developer website, which has the following structure:
bin
include
lib
share
And a dynamic library of gstreamer for mingw with the following structure:
bin
lib
How am I supposed to let mingw/msys know that the gstreamer library is installed? Do I place the folders above in the relevant MSYS directories? Then, how does the configure know that it's installed and ready to be used?
I hope what I'm asking makes sense, please let me know if anything is confused. Cheers!
Using the first solution (official binaries from GStreamer), you need to tell the configure script where everything is located.
The simplest way is to set the environment variable PKG_CONFIG_PATH to where the .pc files are located. Generally it's in
$install_directory/lib/pkgconfig/
Replace $install_directory with the actual location, ex if it's installed in /c/GStreamer :
PKG_CONFIG_PATH=/c/GStreamer/lib/pkgconfig ./configure
That should make configure figure out everything

How can I setup linux to compile FORTRAN code into windows binaries?

I'm working on a FORTRAN project and I would like to build all of the binaries that I want to maintain on a linux machine that is dedicated for automated builds. I have successfully used mingw to build 32-bit and 64-bit binaries from C source for windows machines on the linux machine with the following packages on Ubuntu.
apt-get install mingw32
apt-get install mingw-w64
Then I run the following commands to actually compile:
gcc -b amd64-mingw32msvc -V 4.4.4 -o <...other options>
However, the mingw packages that I've obtained via apt-get do not include FORTRAN compilers.
Anybody got any ideas on what I can do?
if you got mingw32 and the Gnu C cross compiler is working for you ... when why not just get the Gnu Fortran cross compiler, too?
http://www.nber.org/sys-admin/mingw32-fortran-fedora.html
EXAMPLE apt-get install mingw32-gcc-fortran
I know this is an old thread but a few things seem to have changed and people might still be interested in the topic.
Problem: I want to use my linux machine to compile some code and create a .exe that I can send to people using Windows.
Solution: Essentially here: http ://mxe.cc/
What I did:
Check to see if your system has all the software you need here
run
git clone -b stable https://github.com/mxe/mxe.git
It will download a few small things and create the directory "mxe" (probably in your home folder)
cd into that mxe directory and run "make". HOWEVER: this would take hours and take up a few GB on your hard drive so instead run something like
make mpfr eigen opencsg cgal qt
For more ideas on how to shorten that all see this or the mxe tutorial or somewhere else ;)
The easiest way to compile stuff then seems to be something like:
~/mxe/usr/bin/i686-pc-mingw32-gfortran -c main.f95
~/mxe/usr/bin/i686-pc-mingw32-gfortran main.o -o outfile.exe
Of course you can chose something other than fortran, just consult the mxe/usr/bin to see what its called.
You can always download and install a prebuilt compiler from the MinGW(-w64) project itself:
Windows 64-bit: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/4.6.2-1/
Windows 32-bit: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/4.6.2-1/
Just unpack somewhere and add the cross*/bin directory to PATH.
I include (obj)c(++) and fortran.
On Ubuntu 18.04 I use
apt install gfortran-mingw-w64
Then use the compiler x86_64-w64-mingw32-gfortran in place of gfortran. If you're using cmake, you can configure the compiler from the build directory like so:
FC=x86_64-w64-mingw32-gfortran cmake ..

LLVM MinGW installation on Vista?

From llvm.org I've downloaded llvm-2.6-x86-mingw32.tar.bz2 into c:\llvm and llvm-gcc-4.2-2.6-x86-mingw32-tar.bz2 into c:\llvm-gcc as well as setup a desktop shortcut the following batch file in c:\llvm-gcc which attempts to setup an environment for compiling via the llvm-gcc command line too:
#echo off
color 0E
echo Configuring LLVM environment...
set LLVM_LIB_SEARCH_PATH=%~dp0lib
set PATH=c:\llvm;%~dp0bin;%PATH%
Unfortunately, this setup gives the following error when trying to compile a simple hello world program:
C:\CDev\sandbox>llvm-gcc -o hello.exe hello.c
llvm-gcc: CreateProcess: No such file or directory
I've briefly looked through the LLVM binaries and it appears that the MinGW-based Win32 API and runtime files are already included. I also tried adding the MinGW DLL to c:\llvm-gcc\bin to no avail.
What have I missed in setting up the binary LLVM environment and GCC-based front end on Vista?
Thanks, Jon
Because the GNU/MinGW assembler 'as' was required by 'llvm-gcc' to generate the obj file. The problem can be solved by using:
Install GNU/MinGW binutils, extract the as.exe into c:\llvm-gcc\bin
Install a full MinGW package, add %MinGW%\bin your %PATH%
#rwallace is correct that one needs to also install MinGW's binutils along with the LLVM binary download. I've updated the LLVM documentation appropriately at
http://llvm.org/docs/GettingStarted.html#installcf
As far as I can tell, the answer is that the MinGW distribution supplied by LLVM is not complete, in particular, it doesn't come with the 'binutils' programs.
The recommended solution seems to be to download and install MinGW yourself. However, the MinGW download page seems to be saying this requires 10 different packages to be downloaded and installed separately.
The solution I tried today was to use the MinGW that comes with Qt, which does come in a single package; thus far, that appears to work.
It seems like it is looking for the base MinGW installation in C:\MinGW. I just had this error today using gcc.exe in msys. To solve it, I created a symbolic link from c:\msys to c:\MinGW and everything worked.

Resources