Je voudrais ajouter une icône à mon exe compilé avec mingw-gcc.impossible d'ajouter une icône à exe en utilisant windres
J'ai suivi les instructions dans this SO post mais l'icône n'apparaît pas sur mon exe dans Windows Explorer.
[modifier] Pendant ce temps, je trouve que mon windres
détruit exécutable. Avant d'appliquer windres, l'exécutable s'exécute comme prévu. Après avoir appliqué windres
appelant les résultats exécutables dans un message d'erreur Windows indiquant (grosso modo) que cet exécutable n'est pas compatible avec cette version de Windows.
Qu'est-ce que je fais mal?
C'est ma mise en page du répertoire:
$ ls -lR launcher/
launcher/:
total 508
drwxr-xr-x 1 me 1049089 0 Aug 20 2015 src/
drwxr-xr-x 1 me 1049089 0 Nov 7 10:56 target/
launcher/src:
total 0
drwxr-xr-x 1 me 1049089 0 Nov 7 10:51 main/
launcher/src/main:
total 4
drwxr-xr-x 1 me 1049089 0 Nov 7 10:52 cpp/
drwxr-xr-x 1 me 1049089 0 Apr 14 2016 resources/
drwxr-xr-x 1 me 1049089 0 Nov 4 15:11 scripts/
launcher/src/main/cpp:
total 8
-rw-r--r-- 1 me 1049089 6793 Nov 7 10:41 JavaLauncher.cpp
launcher/src/main/resources:
total 5
-rw-r--r-- 1 me 1049089 47 Nov 7 10:47 javaLauncher.rc
-rw-r--r-- 1 me 1049089 2238 Apr 14 2016 JavaLauncher.ico
launcher/src/main/scripts:
total 1
-rw-r--r-- 1 me 1049089 389 Nov 7 10:56 makefile
launcher/target:
total 4
-rwxr-xr-x 1 me 1049089 2502 Nov 7 10:56 JavaLauncher.exe*
c'est mon fichier de ressources:
0 ICON "launcher/src/main/resources/JavaLauncher.ico"
ceci est mon makefile:
all: launcher/target/JavaLauncher.exe
launcher/target/JavaLauncher.exe: launcher/src/main/cpp/JavaLauncher.cpp launcher\target
/Absolute/Path/to/mingw64/bin/g++.exe $< -o [email protected] -static -l winpthread
/Absolute/Path/to/mingw64/bin/windres.exe -v -i launcher/src/main/resources/javaLauncher.rc -o [email protected]
launcher\target:
cmd /c md [email protected]
c'est la sortie faire:
/Project/root>/Absolute/Path/to/mingw64\bin\make.exe -f launcher\src\main\scripts\makefile
cmd /c md launcher\target
/Absolute/Path/to/mingw64/bin/g++.exe launcher/src/main/cpp/JavaLauncher.cpp -o launcher/target/JavaLauncher.exe -static -l winpthread
/Absolute/Path/to/mingw64/bin/windres.exe -v -i launcher/src/main/resources/javaLauncher.rc -o launcher/target/JavaLauncher.exe
Using `/Absolute/Path/to/mingw64/bin/gcc -E -xc -DRC_INVOKED launcher/src/main/resources/javaLauncher.rc'
Using popen to read preprocessor output
/Project/root>
ceci est le résultat dans l'explorateur Windows:
[modifier] La solution finale de travail est la suivante:
mingwPath = $(realpath Path/to/mingw64/bin)
TARGET_DIR=target
TARGET_OBJECT_DIR=$(TARGET_DIR)/objects
TARGET_DIR_NAME=$(subst /,\, $(TARGET_DIR))
TARGET_OBJECT_DIR_NAME=$(subst /,\, $(TARGET_OBJECT_DIR))
SOURCE_DIR_NAME=src/main
APP_NAME=MyApp
TARGET_BASE_NAME=$(TARGET_DIR)/$(APP_NAME)
TARGET_ARCH=-m32
all: $(TARGET_OBJECT_DIR_NAME) $(TARGET_BASE_NAME).exe
$(TARGET_BASE_NAME).exe: $(TARGET_OBJECT_DIR)/$(APP_NAME).o\
$(TARGET_OBJECT_DIR)/$(APP_NAME)Res.o $(TARGET_OBJECT_DIR_NAME)
$(mingwPath)/g++ $(TARGET_ARCH) -o [email protected] -static -l winpthread $(filter %.o,$^)
$(TARGET_OBJECT_DIR)/$(APP_NAME).o: $(SOURCE_DIR_NAME)/cpp/$(APP_NAME).cpp
$(mingwPath)/g++ $(TARGET_ARCH) -c $< -o [email protected]
$(TARGET_OBJECT_DIR)/$(APP_NAME)Res.o: $(SOURCE_DIR_NAME)/resources/$(APP_NAME).rc
$(mingwPath)/windres -v -i $< -o [email protected] --output-format=coff --target=pe-i386
$(TARGET_OBJECT_DIR_NAME):$(TARGET_DIR_NAME)
echo [email protected]
cmd /c md [email protected]
$(TARGET_DIR_NAME):
echo [email protected]
cmd /c md [email protected]
clean:
cmd /c del /s /q $(TARGET_DIR_NAME)
toujours pas en mesure de confirmer maintenant que je suis tombé sur un problème avec la cible 32 bits. Voir ici: http://stackoverflow.com/questions/40584265/undefined-reference-to-winmain16-after-applying-windes –
Avez-vous essayé ce que je vous ai dit, pour changer l'ordre windres et le fichier objet qu'il génère? Ensuite, ajoutez ce fichier objet à l'éditeur de liens g ++ après le '-o $ @' –
oui, le nouveau fichier make crée d'abord un fichier * .o sur lequel windres ajoute l'icône. C'est ce que j'ai compris de votre réponse. –