I'm trying to build GLEW 2.1.0 on Windows (8.1) using MinGW and have been struggling for a while now.
I tried to follow the instructions for "MSYS/Mingw" on the GLEW GitHub page but when running mingw32-make, I only got a couple errors about missing commands (test and config) as well as the following: Makefile:40: *** "Platform '' not supported". Stop.
Under "Requirements" it says that bash is needed, so I installed git, because that apparently comes with a version of bash. Running mingw32-make (in the directory that all the GLEW files and folders are in) using Git Bash results in a long list of warnings and "undefined reference"s. The latter come from the linker as far as I know, but I have no idea what could cause them. As it's so much text, I'll only include the last few lines here:
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0x181b): undefined reference to `_imp___iob'
collect2.exe: error: ld returned 1 exit status
Makefile:181: recipe for target 'bin/glewinfo.exe' failed
mingw32-make: *** [bin/glewinfo.exe] Error 1
mingw32-make install has the following output:
$ mingw32-make install
install -d -m 0755 "/usr/include/GL"
install -m 0644 include/GL/wglew.h "/usr/include/GL/"
install -m 0644 include/GL/glew.h "/usr/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/include/GL/"
sed \
-e "s|#prefix#|/usr|g" \
-e "s|#libdir#|/usr/lib|g" \
-e "s|#exec_prefix#|/usr/bin|g" \
-e "s|#includedir#|/usr/include/GL|g" \
-e "s|#version#|2.1.0|g" \
-e "s|#cflags#||g" \
-e "s|#libname#|glew32|g" \
-e "s|#requireslib#|glu|g" \
< glew.pc.in > glew.pc
install -d -m 0755 "/usr/lib"
install -d -m 0755 "/usr/bin"
install -m 0755 lib/glew32.dll "/usr/bin/"
install -m 0644 lib/libglew32.dll.a "/usr/lib/"
install -m 0644 lib/libglew32.a "/usr/lib/"
install -d -m 0755 "/usr/lib/pkgconfig"
install -d -m 0755 "/usr/lib/pkgconfig"
install -m 0644 glew.pc "/usr/lib/pkgconfig/"
And mingw32-make install.all produces another long list of undefined references and the same error that came from running mingw32-make. The first lines however are (about) the same as the result of running mingw32-make install.
As expected with all of the errors, running these commands didn't produce a binary file. I guess it could have something to do with me not having make, which is one of the requirements listed on the GitHub page. However I don't understand how I should install make on Windows and why it is even needed when the instructions say to use mingw32-make.
I've also tried some of the suggestions made in this thread, but that doesn't seem to have worked either.
What could be the problem and what can I do to successfully compile GLEW?
I could never build it with the instructions I found around the internet, so here's how I build glew (using https://downloads.sourceforge.net/project/glew/glew/2.2.0/glew-2.2.0.tgz) under MSYS2 with MinGW-w64:
# change the line below to your desired install path
INSTALLPREFIX=/usr/local
VERSION=2.2.0
gcc -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32.a src/glew.o &&
gcc -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32mx.a src/glew.mx.o &&
gcc -O2 -c -Iinclude -o src/glewinfo.o src/glewinfo.c &&
gcc -s -o src/glewinfo.exe src/glewinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 &&
gcc -O2 -c -Iinclude -o src/visualinfo.o src/visualinfo.c &&
gcc -s -o src/visualinfo.exe src/visualinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 -lglu32 &&
sed -e "s?#prefix#?$INSTALLPREFIX?; s?#libdir#?\$\{prefix\}/lib?; s?#version#?$VERSION?; s?#requireslib#?glu?; s?#cflags#??; s?#libname#?glew32?" glew.pc.in > glew.pc &&
sed -e "s?#prefix#?$INSTALLPREFIX?; s?#libdir#?\$\{prefix\}/lib?; s?#version#?$VERSION?; s?#requireslib#?glu?; s?#cflags#?-DGLEW_MX?; s?#libname#?glew32mx?" glew.pc.in > glewmx.pc &&
echo Installing... &&
mkdir -p $INSTALLPREFIX/include $INSTALLPREFIX/lib/pkgconfig $INSTALLPREFIX/bin $INSTALLPREFIX/cmake &&
cp -rf include/GL $INSTALLPREFIX/include/ &&
cp -f lib/*.a $INSTALLPREFIX/lib/ &&
cp -f *.pc $INSTALLPREFIX/lib/pkgconfig/ &&
cp -f lib/*.dll src/*.exe $INSTALLPREFIX/bin/ &&
cp -f build/cmake/*.cmake $INSTALLPREFIX/cmake/ &&
echo Success
Related
Trying to install PktGen with DPDK 21.11, however I am getting the below error
[1/69] Compiling C object lib/common/libcommon.a.p/copyright_info.c.o
FAILED: lib/common/libcommon.a.p/copyright_info.c.o
cc -Ilib/common/libcommon.a.p -Ilib/common -I../lib/common -I/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -O3 -march=native -mavx -mavx2 -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE -Wno-pedantic -Wno-format-truncation -fPIC -include rte_config.h -march=native -mno-avx512f -MD -MQ lib/common/libcommon.a.p/copyright_info.c.o -MF lib/common/libcommon.a.p/copyright_info.c.o.d -o lib/common/libcommon.a.p/copyright_info.c.o -c ../lib/common/copyright_info.c
cc1: fatal error: rte_config.h: No such file or directory
compilation terminated.
I think I am missing some environmental variable?
23:45:08 [root:~/Pktgen-DPDK] dev* ± echo $RTE_SDK
/root/repo/gNB_CU/ngp/thirdparty/dpdk/dpdk-21.11/
23:45:41 [root:~/Pktgen-DPDK] dev* ± echo $RTE_TARGET
x86_64-native-linux-gcc
23:45:46 [root:~/Pktgen-DPDK] dev* ± pkg-config --libs libdpdk
-Wl,--as-needed -L/lib64 -lrte_node -lrte_graph -lrte_flow_classify -lrte_pipeline -lrte_table -lrte_pdump -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_dmadev -lrte_regexdev -lrte_rawdev -lrte_power -lrte_pcapng -lrte_member -lrte_lpm -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_gpudev -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bpf -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs
23:45:54 [root:~/Pktgen-DPDK] dev* ± pkg-config --cflags libdpdk
-I/include -include rte_config.h -march=native -mno-avx512f
23:46:06 [root:~/Pktgen-DPDK] dev* ±
Any suggestion where I might have gone wrong?
Problem was in DPDK installation path.
wget http://fast.dpdk.org/rel/dpdk-21.11.tar.xz
tar -xf dpdk-21.11.tar.xz
cd dpdk-21.11/
meson -Dexamples=all build
ninja -C build
cd build
ninja install
ldconfig
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/
Once this was done, installation was successful.
Right, so I have been trying for weeks now to get ImGui to work with my windows OpenGL project. I have tried everything. So, can someone please show me how to compile ImGui with the rest of my project. Like how to add it to the vs code task file or how to add it to my makefile. Also when I have asked before people have said use CMake. But I can't because CMake doesn't work so I can't use it and I don't want to waste more time to try and get it to work. So, anyone who knows how to help please do.
Here is my makefile:
CXX = g++
Flags = -std=c++17 -Wall -Wformat
Libs = -lGL -lGLEW -lglfw -ldl
OBJDIR = obj
VSXFLAGS = src/vendor/imgui/imgui_impl_glfw.h src/vendor/imgui/imgui_impl_opengl3.h
Filez = src/Rendering/*.cpp src/Rendering/*.h src/Core/*.h src/Core/*.cpp src/vendor/glm/gtc/type_ptr.hpp
Includes = -Isrc/PCH/ -Isrc/ -Iinclude/ -Isrc/Rendering/Buffers/ -Isrc/Core/ -Isrc/Rendering/ -Isrc/vendor/imgui -Isrc/FileManagement/ -Ires/ -Isrc/vendor/glm/ -Isrc/vendor/stb_image -Isrc/vendor/
all: main.cpp
$(CXX) $(Flags) $(Includes) $(Filez) main.cpp lib/imgui.a lib/Buffers.a -o main $(Libs)
clean:
rm $(OBJDIR)/*.o *.o
This is my file structure:
[]2
As ImGui is a separate library your project should link against it rather than compiling it with the rest of your project each time.
Here's how I build the library (both static and shared) in MSYS2 shell:
# change the next value to where you want to install it
export INSTALLPREFIX=/D/Prog/3rdparty
# fix DLL exports in imgui.h
mv imgui.h imgui.h.bak
cat > imgui.h << EOF
#if !defined(IMGUI_API) && defined(_WIN32)
#if defined(BUILD_IMGUI_SHARED)
#define IMGUI_API __declspec(dllexport)
#elif !defined(STATIC) && !defined(STATIC_IMGUI)
#define IMGUI_API __declspec(dllimport)
#else
#define IMGUI_API
#endif
#endif
EOF
sed -e "s/static char\s*EmptyString/IMGUI_API &/" imgui.h.bak >> imgui.h
# don't export inline functions in imgui_internal.h (version >= 1.81)
sed -i.bak -e "s/IMGUI_API \(~*ImGuiTable()\)/\1/" imgui_internal.h
~/buildstatus.sh build &&
touch SUCCESS &&
for F in *.cpp; do
echo CXX $F &&
g++ -O3 -I. $F -c -o $F.o -DBUILD_IMGUI_SHARED || rm -f SUCCESS
done &&
ls -1 SUCCESS > /dev/null &&
ar cru libimgui.a *.cpp.o &&
( echo EXPORTS; nm -f posix --defined-only -p libimgui.a | sed -n -e "s/^\([^ ]*\) T .*$/\1/p" | sed -e "s/^__*/_/" | grep "Im" ) > imgui.def &&
g++ -shared -s -mwindows -def imgui.def -o imgui.dll libimgui.a -Wl,--out-implib,libimgui.dll.a -Wl,--as-needed -limm32 &&
~/buildstatus.sh install &&
mkdir -p $INSTALLPREFIX/include/imgui $INSTALLPREFIX/lib $INSTALLPREFIX/bin &&
cp -f *.cpp *.h $INSTALLPREFIX/include/imgui/ &&
cp -f *.a $INSTALLPREFIX/lib/ &&
cp -f *.dll $INSTALLPREFIX/bin/ &&
echo SUCCESS
Make sure your MSYS2 environment points to the same compiler as VSCode in case its different (add to PATH).
My build was done with a recent standalone GCC/MinGW-w64 from https://winlibs.com/
Bit of a "hole in my bucket problem", here.
To start from the top, I was compiling musl-libc when I got an error claiming "can not be used when making a PIE object; recompile with -fPIE". It was pointing to some crto library that would have been packaged with gcc.
Okay, so...I assume I would have to recompile gcc at this point? That's fine, I'll give it a shot.
Except, now I'm running into this same error while trying to recompile gcc.
EDIT (The Error, or at least some of it):
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: gcov.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: json.o: relocation R_X86_64_32 against symbol `_ZTVN4json6objectE' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: hash-table.o: relocation R_X86_64_32S against symbol `prime_tab' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: ggc-none.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: libcommon.a(diagnostic.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
For ease, I've created a dockerfile that should reliably reproduce the error. The contents of the dockerfile are:
# docker build --rm --squash --tag gcc:dev -f ./Dockerfile
# docker run -it --rm --name gcc-dev gcc:dev
ARG JOBS=8
ARG CC=clang
ARG CXX=clang++
FROM alpine:edge as prep
ARG JOBS
ARG CC
ARG CXX
WORKDIR /root/work
RUN apk update && apk upgrade && apk add --no-cache make g++ clang
FROM prep AS gcc-build
ARG JOBS
ARG CC=gcc
ARG CXX=g++
ENV \
CFLAGS="-fpic -fPIE -fpie -static -static-libgcc" \
CXXFLAGS="-fpic -fPIE -fpie -static" \
LDFLAGS=""
ADD https://bigsearcher.com/mirrors/gcc/releases/gcc-10.2.0/gcc-10.2.0.tar.gz .
# COPY gcc/gcc-10.2.0.tar.gz .
RUN \
echo Adding gcc dependencies... && \
apk add gmp-dev mpfr-dev mpc1-dev isl-dev linux-headers && \
echo Building gcc... && \
echo Unpacking gcc... && \
tar zxf gcc-10.2.0.tar.gz && \
echo Moving gcc source files... && \
mv gcc-10.2.0/* . && rm -rf gcc-10.2.0 *.tar.gz && \
echo Configuring gcc... && \
./configure \
--build=x86_64-unknown-linux-musl \
--host=x86_64-unknown-linux-musl \
--target=x86_64-unknown-linux-musl \
# --prefix=/opt/gcc && \
--enable-languages=c,c++ \
--enable-default-pie \
--disable-shared \
--disable-nls \
--with-static-standard-libraries \
--with-stage1-ldflags="-static-pie" \
--with-boot-ldflags="-static-pie" \
--disable-multilib && \
time make -j${JOBS} bootstrap && \
apk del g++ gcc && \
make install
I had run into the error when leaving out the stage 1 -static-pie LDFLAGS. To make the error reproduce quickly, I've set the make target to bootstrap and included the stage 1 -static-pie LDFLAG, but I'm not totally convinced this is necessarily a good indicator of the nature of the error.
I will note that no matter what CFLAGS or CXXFLAGS I have, much of the bootstrapped and stage 2 gcc compilation occurs with something like the following command:
g++ -std=gnu++98 -fno-PIE -c -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -I. -I. -I../.././gcc -I../.././gcc/. -I../.././gcc/../include -I../.././gcc/../libcpp/include -I../.././gcc/../libdecnumber -I../.././gcc/../libdecnumber/bid -I../libdecnumber -I../.././gcc/../libbacktrace -o insn-output.o -MT insn-output.o -MMD -MP -MF ./.deps/insn-output.TPo insn-output.c
i.e. Its always passing the -fno-PIE flag. I would expect I need to get rid of that flag, but I can't find where I do such a thing.
So...how do I create a gcc package that I can use to create static PIE executables?
I got this to work but I had to compile basically the entire LLVM toolchain for x64 musl. Not sure if it ended up being compiler-rt, or libc++/libc++abi, but eventually I could bootstrap the LLVM toolchain using the -fPIE flag appropriately.
I've since given up on that entire endeavor. Its a nightmare trying to keep track of who's bootstraps are bootstrapping who's bootstraps.
I'm trying to build mkspiffs for windows. It's a c/c++ project. I installed mingw, and added it to my path.
The README.md says to run
$ git submodule update --init
$ make dist
The make dist command gives me the following output:
File not found - *.c
cc -std=gnu99 -Os -Wall -mno-ms-bitfields -Itclap -Iinclude -Ispiffs/src -I. -D VERSION=\"0.2.3-6-g983970e\" -D SPIFFS_VERSION=\"0.3.7-5-gf5e26c4\" -D BUILD_CONFIG=\"\" -D BUILD_CONFIG_NAME=\"-generic\" -D __NO_INLINE__ -c -o spiffs/src/spiffs_cache.o spiffs/src/spiffs_cache.c
process_begin: CreateProcess(NULL, cc -std=gnu99 -Os -Wall -mno-ms-bitfields -Itclap -Iinclude -Ispiffs/src -I. -D VERSION=\"0.2.3-6-g983970e\" -D SPIFFS_VERSION=\"0.3.7-5-gf5e26c4\" -D BUILD_CONFIG=\"\" -D BUILD_CONFIG_NAME=\"-generic\" -D __NO_INLINE__ -c -o spiffs/src/spiffs_cache.o spiffs/src/spiffs_cache.c, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [spiffs/src/spiffs_cache.o] Error 2
I'm using mingw64.
C:\Users\peterkapteyn>where gcc
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe
I am a novice when it comes to building things from source/using makefiles and that sort of thing. Can anyone offer some insight into what's going on?
I have downloaded the source of some old project. I'm trying to build it now:
./bootstrap && ./configure
It works fine, but:
make
/bin/sh ../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -W -g -O2 -DDEBUG -MT rcclexer.lo -MD -MP -MF .deps/rcclexer.Tpo -c -o rcclexer.lo rcclexer.cpp
../libtool: line 415: CDPATH: command not found
libtool: Version mismatch error. This is libtool 2.4.2, but the
libtool: definition of this LT_INIT comes from an older release.
libtool: You should recreate aclocal.m4 with macros from libtool 2.4.2
libtool: and run autoconf again.
p.s. that small project page: http://sourceforge.net/projects/rccparser/
Any help?
Something like:
autoreconf -fvi
maybe? I'd hope bootstrap would take care of that though, but it looks like it doesn't.