I would like to use eclipse IDE for my development with Tiva (LM4F) processor. I did this tutorial. Kernel hacks tutorial.
I use Win 8.1 x64 + eclipse + ARM-GCC and I would like to program a LM4F MCU.
I sat up everything, compiler path, the driverlib path. But It can't find the correct dependencies
Invoking: Cross GCC Compiler
arm-none-eabi-gcc -DPART_LM4F120H5QR -DTARGET_IS_BLIZZARD_RA1 -DARM_MATH_CM4 -I../.. /../stellarisware/ -I../../../stellarisware/utils -I../../../stellarisware/driverlib -I../../../stellarisware/inc/ -O0 -g3 -Wall -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.c"
c:/gnu_gcc_arm/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/armv7e-m/softfp\libg.a(lib_a-exit.o): In function 'exit':
exit.c:(.text.exit+0x16): undefined reference to '_exit'
C:\Users\MTYS~1\AppData\Local\Temp\ccECjb0N.o: In function 'Init_Adc':
C:\eclipse_workspace\proba\Debug/../main.c:20: undefined reference to 'SysCtlPeripheralEnable'
And all of driver functions gave me error.
And my path is (windows path: C:\stellarisware\, the project folder is C:\eclipse_workspace\try):
../../../stellarisware/
../../../stellarisware/utils
../../../stellarisware/driverlib
../../../stellarisware/inc/
I tried different methods (use cygwin path, or absolute windows path), the code can be compiled successfully with IAR. What should I do?
Related
I'm failing to build the simple Hello World C++ CMake Project in Eclipse with Yocto plugin. Yocto's version is "thud".
The local.conf have the line:
TOOLCHAIN_HOST_TASK_append += " nativesdk-cmake"
I've build the sdk
bitbake myBoard -c populate_sdk
I've installed the sdk, sourced the enviroment setup, launched eclipse from the same terminal and configured the yocto plugin.
The enviroment script have the following variable:
export SDKTARGETSYSROOT=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
export CC="arm-fslc-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT"
export CXX="arm-fslc-linux-gnueabi-g++ -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT"
export CPP="arm-fslc-linux-gnueabi-gcc -E -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT"
When I try to build I have the following output (even sourcing the sdk's enviroment setup and then cmake from command line):
$ cmake ..
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc
-- Check for working C compiler: /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc -- broken
CMake Error at /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /yocto/eclipse-ws/prova/Debug/CMakeFiles/CMakeTmp
Run Build Command:"/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/bin/make" "cmTC_4df0b/fast"
/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/bin/make: 1: /yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/bin/make: Syntax error: word unexpected (expecting ")")
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:4 (PROJECT)
-- Configuring incomplete, errors occurred!
See also "/yocto/eclipse-ws/prova/Debug/CMakeFiles/CMakeOutput.log".
See also "/yocto/eclipse-ws/prova/Debug/CMakeFiles/CMakeError.log".
Someone see something wrong or missing that is causing the error?
Thank you in advance for any help
Update
The CMakeOutput.log show:
The system is: Linux - 4.15.0-47-generic - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc
Build flags: ;;;--sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi;;-march=armv7-a;-mthumb;-mfpu=neon;-mfloat-abi=hard;
Id flags:
The output was:
0
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"
The C compiler identification is GNU, found in "/yocto/eclipse-ws/prova/Debug/CMakeFiles/3.12.2/CompilerIdC/a.out"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-g++
Build flags: ;;;--sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi;;-march=armv7-a;-mthumb;-mfpu=neon;-mfloat-abi=hard;;-fpermissive
Id flags:
The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
The CXX compiler identification is GNU, found in "/yocto/eclipse-ws/prova/Debug/CMakeFiles/3.12.2/CompilerIdCXX/a.out"
Update 2
If I remove everything from the Debug folder and run cmake from command line I have a success and I can build even in Eclipse. If I change something in CMakeLists.txt then the error show up again.
I see that Debug/CMakeFiles/3.12.2/CMakeSystem.cmake is different when it is generated by eclipse or by command line:
Eclipse)
set(CMAKE_HOST_SYSTEM "Linux-4.15.0-47-generic")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "4.15.0-47-generic")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")
include("/yocto/eclipse-ws/prova/toolchain.cmake")
set(CMAKE_SYSTEM "Linux-4.15.0-47-generic")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "4.15.0-47-generic")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
set(CMAKE_CROSSCOMPILING "FALSE")
set(CMAKE_SYSTEM_LOADED 1)
Command Line)
set(CMAKE_HOST_SYSTEM "Linux-4.15.0-47-generic")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "4.15.0-47-generic")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")
include("/yocto/sdk/aw70pc_am8000/sysroots/x86_64-fslcsdk-linux/usr/share/cmake/OEToolchainConfig.cmake")
set(CMAKE_SYSTEM "Linux")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "")
set(CMAKE_SYSTEM_PROCESSOR "armv7at2hf-neon-fslc")
set(CMAKE_CROSSCOMPILING "TRUE")
set(CMAKE_SYSTEM_LOADED 1)
From what I understand the eclipse plugin is generating a configuration that use the arm toolchain to compile a test program, not crosscompiling, and obviously it fail. Cmake from command line instead generate it the right way but it's overwritten by the first change in eclipse.
Here's the printenv as requested by danlor
ARCH=arm
CONFIG_SITE=/yocto/sdk/myBoard/site-config-armv7at2hf-neon-fslc-linux-gnueabi
SDKTARGETSYSROOT=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
CFLAGS= -O2 -pipe -g -feliminate-unused-debug-types
KCFLAGS=--sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
OECORE_ACLOCAL_OPTS=-I /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/share/aclocal
CC=arm-fslc-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
OECORE_DISTRO_VERSION=2.6
OECORE_SDK_VERSION=2.6.1
PKG_CONFIG_SYSROOT_DIR=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
CXXFLAGS= -O2 -pipe -g -feliminate-unused-debug-types
STRIP=arm-fslc-linux-gnueabi-strip
OBJCOPY=arm-fslc-linux-gnueabi-objcopy
CONFIGURE_FLAGS=--target=arm-fslc-linux-gnueabi --host=arm-fslc-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
OECORE_NATIVE_SYSROOT=/yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux
RANLIB=arm-fslc-linux-gnueabi-ranlib
OBJDUMP=arm-fslc-linux-gnueabi-objdump
AS=arm-fslc-linux-gnueabi-as
AR=arm-fslc-linux-gnueabi-ar
TARGET_PREFIX=arm-fslc-linux-gnueabi-
NM=arm-fslc-linux-gnueabi-nm
CXX=arm-fslc-linux-gnueabi-g++ -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
OECORE_TARGET_OS=linux-gnueabi
OECORE_TARGET_ARCH=arm
OECORE_TARGET_SYSROOT=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
CROSS_COMPILE=arm-fslc-linux-gnueabi-
OE_CMAKE_TOOLCHAIN_FILE=/yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/share/cmake/OEToolchainConfig.cmake
CPPFLAGS=
LDFLAGS=-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX=
OECORE_BASELIB=lib
PKG_CONFIG_PATH=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/lib/pkgconfig:/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/share/pkgconfig
CPP=arm-fslc-linux-gnueabi-gcc -E -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
LD=arm-fslc-linux-gnueabi-ld --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
toolchain.cmake
# CMake system name must be something like "Linux".
# This is important for cross-compiling.
set(CMAKE_SYSTEM_PROCESSOR )
set(CMAKE_C_COMPILER arm-fslc-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-fslc-linux-gnueabi-g++)
set(CMAKE_C_FLAGS " --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard " CACHE STRING "CFLAGS")
set(CMAKE_CXX_FLAGS " --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -fpermissive" CACHE STRING "CXXFLAGS")
set(CMAKE_C_FLAGS_RELEASE " --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -DNDEBUG" CACHE STRING "CFLAGS for release")
set(CMAKE_CXX_FLAGS_RELEASE " --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -DNDEBUG" CACHE STRING "CXXFLAGS for release")
set(CMAKE_C_LINK_FLAGS "" CACHE STRING "LDFLAGS")
set(CMAKE_CXX_LINK_FLAGS "" CACHE STRING "LDFLAGS")
# only search in the paths provided so cmake doesnt pick
# up libraries and tools from the native build machine
set(CMAKE_FIND_ROOT_PATH /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux /yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi )
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# Use qt.conf settings
set(ENV{QT_CONF_PATH} qt.conf)
# We need to set the rpath to the correct directory as cmake does not provide any
# directory as rpath by default
set(CMAKE_INSTALL_RPATH )
# Use native cmake modules
set(CMAKE_MODULE_PATH /cmake/Modules/)
# add for non /usr/lib libdir, e.g. /usr/lib64
set(CMAKE_LIBRARY_PATH ${libdir} ${base_libdir})
Workaround
I've found a way out
Adding the following 2 lines in CMakeLists.txt will tell cmake that the compiler works and to not test it
SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)
Now I can build successfully my own program and it works like a charm.
It means that Eclipse can crosscompile my program but when checking the system it build the test program in a different way.
It seems that you're trying to use the cross-compiled make tool (the one that is compiled for your TARGET, i.e. /yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/bin/make) instead of the HOST make tool (/yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/make). Change it and try again :)
I'm building a gst-plugin through yocto 1.6. I've linaro 4.9 cross toolchain of 32 and 64-bit.
When I'm building the plugin using 64-bit toolchain, it was success ( I got the plugin .so file) whereas if I build the same source using 32-bit toolchain I got the below error
/home/build-directory/tmp/sysroots/x86_64-linux/usr/libexec/cortexa8hf-vfp-neon-rdk-linux-gnueabi/gccgcc/arm-rdk-linux-gnueabi/4.9.4/ld: error: .libs/libgstpluginxxx_la-gstpluginxxx.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
here the whole error
./arm-rdk-linux-gnueabi-libtool --tag=CC --tag=disable-static --mode=link arm-rdk-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -fno-omit-frame-pointer -fno-optimize-sibling-calls --sysroot=/home/sysroots/path -pthread -I/home/sysroots/path/usr/include/gstreamer-1.0 -I/home/sysroots/path/usr/include/glib-2.0 -I/home/sysroots/path/usr/lib/glib-2.0/include -O2 -pipe -g -feliminate-unused-debug-types -fPIC -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o libgstpluginxxx.la -rpath /usr/lib/gstreamer-1.0 libgstpluginxxx_la-gstpluginxxx.lo -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0
arm-rdk-linux-gnueabi-libtool: link: arm-rdk-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -enable-shared -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -fno-omit-frame-pointer -fno-optimize-sibling-calls --sysroot=/home/sysroots/path -shared -fPIC -DPIC .libs/libgstpluginxxx_la-gstpluginxxx.o /home/sysroots/path/usr/lib/libgstreamer-1.0.so -L/home/sysroots/path/usr/lib /home/sysroots/path/usr/lib/libgmodule-2.0.so -lm -ldl /home/sysroots/path/usr/lib/libgobject-2.0.so /home/sysroots/path/usr/lib/libffi.so /home/sysroots/path/usr/lib/libglib-2.0.so -lpthread -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/home/sysroots/path -pthread -O2 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -pthread -Wl,-soname -Wl,libgstpluginxxx.so.0 -o .libs/libgstpluginxxx.so.0.0.0
/home/build-directory/tmp/sysroots/x86_64-linux/usr/libexec/cortexa8hf-vfp-neon-rdk-linux-gnueabi/gcc/arm-rdk-linux-gnueabi/4.9.4/ld: error: .libs/libgstpluginxxx_la-gstpluginxxx.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
I was confused, why the build was failed to recompile with -fPIC though it was mentioned in the linking command? I tried -fPIC option manually everywhere in the Makefile and libtool script, but no use :(
and
without modifying the source and recipe file, it was success in 32-bit toolchain whereas failed in 64-bit toolchain and telling to recompile with -fPIC option
Below are the build machine info.
BB_VERSION = "1.28.0"
BUILD_SYS = "i686-linux"
NATIVELSBSTRING = "Ubuntu-14.04"
This is likely a bug in gold linker. similar to
https://sourceware.org/ml/binutils/2010-12/msg00473.html
It seems you are using gold linker as default ld. So please pass
LDFLAGS += "-fuse-ld=bfd"
in recipe for this package. and see if that helps. This will force GNU BFD linker to be used for this package.
I was confused, why the build was failed to recompile with -fPIC though it was mentioned in the linking command? I tried -fPIC option manually everywhere in the Makefile and libtool script, but no use :(
Regarding these statements...
make distclean should clean all artifacts so everything gets rebuilt. You will also need to reconfigure.
Before you reconfigure, open your configure.ac and be sure you have a LT_INIT that includes pic-only:
AC_INIT([Crypto++], [8.3], ...)
LT_INIT([pic-only,enable-shared,enable-static])
AM_INIT_AUTOMAKE
...
This is the first time I started use Dlib library.
I make a project and include dlib's face detection example cpp.
I have already linked to pthread and -std=c++1 into my project.
I have already included the folder path which has dlib folder inside.
I have already included source.cpp into my project.
When I build, I have errors from this source.cpp as
15:43:22 * Build of configuration Debug for project ObjectDetectionDlib *
make all
Building file: ../src/ObjectDetectionDlib.cpp
Invoking: GCC C++ Compiler
g++ -DGXX_EXPERIMENTAL_CXX0X -I/home/nyan/Softwares/Dlib_Lib/ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"src/ObjectDetectionDlib.d" -MT"src/ObjectDetectionDlib.o" -o "src/ObjectDetectionDlib.o" "../src/ObjectDetectionDlib.cpp"
Finished building: ../src/ObjectDetectionDlib.cpp
Building file: ../src/source.cpp
Invoking: GCC C++ Compiler
g++ -DGXX_EXPERIMENTAL_CXX0X -I/home/nyan/Softwares/Dlib_Lib/ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"src/source.d" -MT"src/source.o" -o "src/source.o" "../src/source.cpp"
../src/source.cpp:7:41: fatal error: ../base64/base64_kernel_1.cpp: No such file or directory
#include "../base64/base64_kernel_1.cpp"
^
compilation terminated.
make: *** [src/source.o] Error 1
What is wrong? I use g++/4.8 as compiler.
I am using NetBeans under RedHat. I have a couple of open projects that combine together to make a command line executable and a shared object "plugin". There are two static libraries in the mix as well. That is all fine and good.
I just noticed that when I "clean and build" the executable and the shared object that the compiler options are also expressed on the linker line. a la:
g++ -O2 -Wall -c -fmessage-length=0 -c -g -Werror -DDEBUG -DDEBUG_2 -I/usr/include -I/usr/include/c++/4.4.7/x86_64-redhat-linux -I/usr/include/c++/4.4.7 -I../ITGUtilities -MMD -MP -MF "build/Debug/GNU-Linux-x86/LocalCache.o.d" -o build/Debug/GNU-Linux-x86/LocalCache.o LocalCache.cpp
then later in the compile line (edited for brevity):
g++ -O2 -Wall -c -fmessage-length=0 -fPIC -o dist/Debug/GNU-Linux-x86/pam_plugin.so build/Debug/GNU-Linux-x86/pam_plugin.o -L... -lpam -l... -shared -fPIC
g++: build/Debug/GNU-Linux-x86/pam_plugin.o: linker input file unused because linking not done
I think I have a fairly generic set of project configs. I did set the -O2 -Wall -c -fmessage-length=0 compiler options but there are no options supplied for the linker other than whatever defaults NetBeans applies.
For the executable and plugin projects I can go to Properties > Linker > Additional Options and expand the [...] to see what NB thinks it will apply. That does not show the compile options but doing an actual build does apply them.
It is not doing the link step and I am assuming that is because of the compiler options. This is weird.
ideas?
Do not add -c option to the compiler options which says not to run the linker. It will be added as needed when just compiling anyway.
I want to write a tool to capture and visualize pressed keys in a specific application so I searched for a sample source.
My result was this:
http://www.codeguru.com/cpp/w-p/system/keyboard/article.php/c5699
But it doesn't work yet. Here's my approach:
I have imported the sources as makefile project in Elipse (Helios, CDT Version 7.0.0.201006141710) using Mingw 4.6.1 as toolchain.
In keydll3.cpp I added the line
#define KEYDLL3_EXPORTS
to tell the preprocessor that i want to export the dll functions.
Now when I try to compile the project, the following errors occour:
**** Internal Builder is used for build ****
g++ -shared -DBUILDING_EXAMPLE_DLL -IC:\MinGW\include -IC:\MinGW\lib\gcc\mingw32\4.6.1\include\c++ -O2 -g -Wall -c -fmessage-length=0 -oStdAfx.o ..\StdAfx.cpp
g++ -shared -DBUILDING_EXAMPLE_DLL -IC:\MinGW\include -IC:\MinGW\lib\gcc\mingw32\4.6.1\include\c++ -O2 -g -Wall -c -fmessage-length=0 -okeydll3.o ..\keydll3.cpp
..\keydll3.cpp:31:0: warning: ignoring #pragma data_seg [-Wunknown-pragmas]
..\keydll3.cpp:34:0: warning: ignoring #pragma data_seg [-Wunknown-pragmas]
..\keydll3.cpp:36:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
g++ -okeydll3 keydll3.o StdAfx.o
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libmingw32.a(main.o): In function `main':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMain#16'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
It seems that the compiler misses the winmain statement because he assume it's a windows application. But a dll isn't.
It also seems that the "-share" option has no effect.
So how do I tell the compiler that my code is a dll with some Windows API calls?
If there's another example which works without visual studio let me know.
Thanks in advance for your contributions.
Noir
You've added the -shared option in the wrong place. It needs to be added to the linker flags, not to the compiler flags. Your commands should look like this.
g++ -DBUILDING_EXAMPLE_DLL -IC:\MinGW\include -IC:\MinGW\lib\gcc\mingw32\4.6.1\include\c++ -O2 -g -Wall -c -fmessage-length=0 -oStdAfx.o ..\StdAfx.cpp
g++ -DBUILDING_EXAMPLE_DLL -IC:\MinGW\include -IC:\MinGW\lib\gcc\mingw32\4.6.1\include\c++ -O2 -g -Wall -c -fmessage-length=0 -okeydll3.o ..\keydll3.cpp
g++ -shared -okeydll3 keydll3.o StdAfx.o