Acabei de instalar o Allegro 5 no meu Imac High Sierra ! Realmente o 5 é muito diferente do 4 que conheço bem. Estou apanhando muito com o 5, após passar por uma serie de problemas apareceu este que não consigo sai ! Alguém pode me dar uma luz ! Segue abaixo o erro e o fonte que estou escrevendo ! Lembrando que não sei por qyê aparece um tradutor de texto que altera o que envio, por exemplo aonde se lê retorna ; é "return;" e outros também, porém o código esta correto ! Obrigado ! Estou parado e um cliente me cobrando muito !
Por favor alguém me ajude!!!
bicho.c:89:32: erro: declarador de parâmetro esperado
ALLEGRO_DISPLAY *video(1280,1024);
^
bicho.c:89:32: erro: esperado ')'
bicho.c:89:31: nota: para corresponder a este '('
ALLEGRO_DISPLAY *video(1280,1024);
Segue a fonte!
#include<allegro5/allegro_font.h>
#include<allegro5/allegro_native_dialog.h>
#include<allegro5/allegro_image.h>
#include<allegro5/allegro_opengl.h>
#include<allegro5/blender.h>
#include<allegro5/ allegro_audio.h>
#include<allegro5/drawing.h>
#include<allegro5/color.h>
#include<allegro5/bitmap.h>
#include<allegro5/bitmap_draw.h>
#include<allegro5/keyboard.h>
include<allegro5/mouse.h>
#include<allegro5/keycodes.h>
#include<allegro5/display.h>
#include<allegro5/error.h>
#include<allegro5/events.h>
#include<time.h>
#include<ctype.h>
#include<errno.h>
#include<wchar.h>
#include<stdlib.h>
#include<string.h>
#include<ncurses.h>
#define FUNDO 1
void init(void); // inicia Allegro
void grid(void); // monta tela de apresentação
void shut(void); // desligar o bicho
void faz_aposta(void); // faz aposta
void registra_aposta(void); // registra no banco aposta
void send_aposta(void); // envia aosta por e-mal pi umprime
void customer_write(void); // cadastra no banco cliente (nome ficticio) - leva banco, ag e conta
typedef struct ALLEGRO_DISPLAY *video;
char *dsp = "..";
// int *vídeo = NULL;
int main(int argc, char *argv[])
{
system("clear");
iniciar();
rede();
retorno(0);
}
void init (void)
{
printf("Criando video /n");
ALLEGRO_DISPLAY *vídeo(1280,1024);
// ALLEGRO_DISPLAY *vídeo = NULL;
printf("Criar video /n");
if(!al_init())
{
al_show_native_message_box(NULL, "Aviso", "Erro: ", "Allegro
inicialização errada",NULL,ALLEGRO_MESSAGEBOX_ERROR);
Retorna ;
}
// video = al_create_display (1280, 1024);
if (!*video)
{
al_show_native_message_box(NULL, "Aviso", "Erro: ", "Vídeo não
criado",NULL,ALLEGRO_MESSAGEBOX_ERROR);
Retorna ;
}
al_show_native_message_box(NULL, "Mensagem", "Ok!: ",
"Inicializado",NULL,ALLEGRO_MESSAGEBOX_WARN);
al_rest(10);
Retorna ;
}
Como pode notar ele altera mesmo eu escrevi return; e não retorna;
Tudo parece estar ok agora, porem não consigo encontrar a biblioteca allegro_ttf, no linker ele acusa como not found e não consigo encontra-la ! Tem alguma ideia ?
Você só precisa incluir allegro5\allegro5.h para a biblioteca principal e o cabeçalho para cada módulo que você usa: allegro5\allegro_native_dialog.h, allegro5\allegro_font.h, ...
<code> o código vai aqui para formatar corretamente </code>
/*typedef struct*/ ALLEGRO_DISPLAY *video = NULL; video = al_create_display(1280,1024); //if (!*video) if (!video)
// Como usar typedef // typedef (tipo_definido) (novo_tipo); typedef int meu_tipi_inteiro; meu_tipo_inteiro i = 5; // o typedef struct ALLEGRO_DISPLAY* Poppy; Poppy video = NULL;
Daniel ! Obrigado pela ajuda, agora em tempo de linker está acontecendo isso :
Lembrando Allegro 5 no Imac High Sierra ! Segue o makefile !
MacBook-Air-de-User:bicho maphiaimac$ make
gcc -o bicho.o -c -g -Wall -Wextra `pkg-config --cflags lallegro lallegro_main lallegro_font lallegro_dialog` bicho.c -I /usr/local/include
Package lallegro was not found in the pkg-config search path.
Perhaps you should add the directory containing `lallegro.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lallegro' found
Package lallegro_main was not found in the pkg-config search path.
Perhaps you should add the directory containing `lallegro_main.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lallegro_main' found
Package lallegro_font was not found in the pkg-config search path.
Perhaps you should add the directory containing `lallegro_font.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lallegro_font' found
Package lallegro_dialog was not found in the pkg-config search path.
Perhaps you should add the directory containing `lallegro_dialog.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lallegro_dialog' found
No Linux eu usava o Allegro 4, o 5 é novidade para mim e estou tentando portar para o MacOs os aplicativos porem o Allegro 4 não é suportado no High Sierra !
bicho.c:70:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char *argv)
^
bicho.c:70:27: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char *argv)
^
bicho.c:94:17: warning: implicit declaration of function 'al_creat_display' is invalid in C99 [-Wimplicit-function-declaration]
video = al_creat_display (1280, 1024);
^
bicho.c:94:15: warning: incompatible integer to pointer conversion assigning to 'ALLEGRO_DISPLAY *' (aka 'struct ALLEGRO_DISPLAY *') from 'int' [-Wint-conversion]
video = al_creat_display (1280, 1024);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.
gcc -o bicho bicho.o -Wl,-rpath,/usr/local/lib -lallegro -lallegro_font -lallegro_main -lncurses -lmysqlclient -lallegro_primitives -lallegro_image -lallegro_font -lallegro_dialog
Undefined symbols for architecture x86_64:
"_al_creat_display", referenced from:
_init in bicho.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bicho] Error 1
segue o makefile !
## --------------------------------- ##
## Criado por jamdesalles Apr. 2022
## --------------------------------- ##
CC = gcc
CLANG = -v
CFLAGS = -g -Wall -Wextra `pkg-config --cflags lallegro lallegro_main lallegro_font lallegro_dialog`
OBJECTS = bicho.o
INCFLAGS = -I /usr/local/include
LDFLAGS = -Wl,-rpath,/usr/local/lib
LIBS = -lallegro -lallegro_font -lallegro_main -lncurses -lmysqlclient -lallegro_primitives -lallegro_image -lallegro_font -lallegro_dialog
all: bicho
bicho: $(OBJECTS)
$(CC) -o bicho $(OBJECTS) $(LDFLAGS) $(LIBS)
.SUFFIXES:
.SUFFIXES: .c .cc .C .cpp .o
.c.o :
$(CC) -o $@ -c $(CFLAGS) $< $(INCFLAGS)
count:
wc *.c *.cc *.C *.cpp *.h *.hpp
clean:
rm -f *.o
.PHONY: all
.PHONY: count
.PHONY: clean
Estou portando os aplicativos do Linux para o Macos, porem no High Sierra o Allegro 4 não é suportado por este motivo estou usando o Allegro 5 que é bem diferente do Allegro 4 !
Obrigado !
Ignore os avisos sobre argc e argv
o nome da função está incorreto
O caminho para os arquivos de biblioteca está incorreto. É por isso que make não conseguiu encontrá-los. ou a biblioteca não está lá
Daniel ! Obrigado ! corrigi o create !
você fala do :LDFLAGS = -Wl,-rpath, /usr/local/lib, verifiquei no /usr/local/lib e as bibliotecas estão lá, a não ser que tenha algo errado no LDFLAG0S = -Wl, -rpath ?
Este tradutor : c o r r i g i - o - c r e a t e !
Evoluindo !!! Agora :
Quando do al_creste :Segmentation fault: 11
Corrigi ! Faltava inicializar o Allegro ! Obrigado !
Até o proximo pepino !
Consegui evoluir muito !Agora restou um problema no linker :
MacBook-Air-de-User:bicho maphiaimac$ make
gcc -o bicho bicho.o -Wl,-rpath, /usr/local/lib -lallegro -lallegro_font -lallegro_main -lncurses -lmysqlclient -lallegro_primitives -lallegro_image -lallegro_font -lallegro_dialog
Undefined symbols for architecture x86_64:
"_al_init_ttf_addon", referenced from:
_init in bicho.o
"_al_load_ttf_font", referenced from:
_init in bicho.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bicho] Error 1
Acredito que esteja faltando uma biblioteca liga ao allegro_font !
Te peço mais esta ajuda !
ele não encontra a biblioteca allgro_ttf no acima não aparece mais descobri que estava faltando e a inclui !
MacBook-Air-de-User:bicho maphiaimac$ make
gcc -o bicho bicho.o -Wl,-rpath, /usr/local/lib -lallegro -lallegro_main -lncurses -lmysqlclient -lallegro_primitives -lallegro_image -lallegro_font -lallegro_ttf -lallegro_dialog -lallegro_color -lallegro_audio -allegro_codec -allegro_memfile
clang: warning: argument unused during compilation: '-allegro_codec' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-allegro_memfile' [-Wunused-command-line-argument]
ld: library not found for -lallegro_ttf
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bicho] Error 1
Tem alguma ideia ?
Ja, hoor eens even. Als we hier allemaal in onze eigen taal gaan ouwehoeren, kan niemand meer iets volgen.
"Doe daabse knien"
Did you install pkg-config? Did you install allegro after pkg-config?
pkg-config --list-all | grep allegro
executei o pkgconfig e não aparece o allegro_ttf, aparec todas as outras allegro_audio, allegro_codec etc... todas, menos a allegro_ttf
Did you build allegro yourself?
Homebrew should have included allegro_ttf addon by default. If not, there's something wrong with the homebrew package.
Tem como baixar esta biblioteca, se sim onde ? Re-instalei o Allegro e continua não vindo a allegro_ttf !
Consegui baixar a biblioteca porem ela exige um link simbólico pois embora a biblioteca exista ele continua dando not found, acredito que seja a falta do link !
Agora o problema evoluiu, é na parte de audio :
MacBook-Air-de-User:bicho maphiaimac$ make
gcc -Wl,-rpath, /usr/local/lib audio.c -o audio
Undefined symbols for architecture x86_64:
"_al_attach_audio_stream_to_mixer", referenced from:
__al_mangled_main in audio-657679.o
"_al_create_display", referenced from:
_inicializar in audio-657679.o
"_al_create_event_queue", referenced from:
_inicializar in audio-657679.o
"_al_destroy_audio_stream", referenced from:
__al_mangled_main in audio-657679.o
"_al_destroy_display", referenced from:
__al_mangled_main in audio-657679.o
_inicializar in audio-657679.o
"_al_destroy_event_queue", referenced from:
__al_mangled_main in audio-657679.o
_inicializar in audio-657679.o
"_al_destroy_sample", referenced from:
__al_mangled_main in audio-657679.o
_inicializar in audio-657679.o
"_al_get_default_mixer", referenced from:
__al_mangled_main in audio-657679.o
"_al_get_display_event_source", referenced from:
_inicializar in audio-657679.o
"_al_get_keyboard_event_source", referenced from:
_inicializar in audio-657679.o
"_al_init_acodec_addon", referenced from:
_inicializar in audio-657679.o
"_al_install_audio", referenced from:
_inicializar in audio-657679.o
"_al_install_keyboard", referenced from:
_inicializar in audio-657679.o
"_al_install_system", referenced from:
_inicializar in audio-657679.o
"_al_is_event_queue_empty", referenced from:
__al_mangled_main in audio-657679.o
"_al_load_audio_stream", referenced from:
_inicializar in audio-657679.o
"_al_load_sample", referenced from:
_inicializar in audio-657679.o
"_al_play_sample", referenced from:
__al_mangled_main in audio-657679.o
"_al_register_event_source", referenced from:
_inicializar in audio-657679.o
"_al_reserve_samples", referenced from:
_inicializar in audio-657679.o
"_al_set_audio_stream_playing", referenced from:
__al_mangled_main in audio-657679.o
"_al_set_window_title", referenced from:
_inicializar in audio-657679.o
"_al_wait_for_event", referenced from:
__al_mangled_main in audio-657679.o
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: __al_mangled_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [audio] Error 1
tenho um outro programa usando as mesmas funções e não da este problema no linker !
You have to link against Allegro. and allegro_main on OSX. I don't know why the TTF addon is missing. Hopefully Peter Hull can help you.
@jamdesalles:
Hola, podes aprender muchas cosas desde estos sitios:
Para aprender te sugiero leer los ejemplos, compilarlos y ejecutarlos, y modificarlos. Y leer la guia para mayor detalle acerca de cualquier funcion.
I think you are nearly there but you need to understand what
pkg-config is for. It takes package names and outputs the
correct command-line options for the compiler or linker. For
Allegro on MacOS you always need at least packages allegro-5 and
allegro_main-5. For fonts you need both allegro_font-5 and
allegro_ttf-5. If you just use it on the command line,
% pkg-config --cflags allegro-5 allegro_main-5
outputs
-I/usr/local/Cellar/allegro/5.2.7.0/include
and
% pkg-config --libs allegro-5 allegro_main-5
outputs
-L/usr/local/Cellar/allegro/5.2.7.0/lib -lallegro_main -lallegro
You could take these options and type them into your Makefile but normally people use the back-ticks which "means run this program and replace with whatever the output is."
In your Makefile you have
CFLAGS = -g -Wall -Wextra `pkg-config --cflags lallegro lallegro_main lallegro_font lallegro_dialog`
This is wrong because 'lallegro' is not a package name, nor are the others. It should be:
CFLAGS = -g -Wall -Wextra `pkg-config --cflags allegro-5 allegro_main-5 allegro_font-5 allegro_dialog-5`
This becomes just
-I/usr/local/Cellar/allegro/5.2.7.0/include
and you do not also need INCFLAGS in your Makefile.
Also you have
LIBS = -lallegro -lallegro_font -lallegro_main -lncurses -lmysqlclient -lallegro_primitives -lallegro_image -lallegro_font -lallegro_dialog LDFLAGS = -Wl,-rpath,/usr/local/lib
This is a job for pkg-config!
LIBS = `pkg-config --libs allegro-5 allegro_main-5 allegro_font-5 allegro_dialog-5`
which becomes
-L/usr/local/Cellar/allegro/5.2.7.0/lib -lallegro_main -lallegro_font -lallegro_dialog -lallegro
On the linker line, make has some pre-defined variables to help you: LINK.o is the correct command for linking .o files. @ means the target (bicho in this case) and < means the input files ($(OBJECTS) in this case)
Putting it together I would write your makefile as
CFLAGS = -g -Wall -Wextra `pkg-config --cflags allegro-5 allegro_main-5 allegro_font-5 allegro_dialog-5` OBJECTS = bicho.o LDLIBS = `pkg-config --libs allegro-5 allegro_main-5 allegro_font-5 allegro_dialog-5` all: bicho bicho: $(OBJECTS) $(LINK.o) -o $@ $< $(LDLIBS) count: wc *.c *.cc *.C *.cpp *.h *.hpp clean: rm -f *.o .PHONY: all .PHONY: count .PHONY: clean
EDIT same thing with Google translate
Eu acho que você está quase lá, mas você precisa entender o propósito de
pkg-config. Ele recebe nomes de pacotes e gera o
opções de linha de comando corretas para o compilador ou vinculador. Por
Allegro no MacOS você sempre precisa de pelo menos pacotes allegro-5 e
allegro_main-5. Para fontes, você precisa de allegro_font-5 e
allegro_ttf-5. Se você apenas usá-lo na linha de comando,
% pkg-config --cflags allegro-5 allegro_main-5 -I/usr/local/Cellar/allegro/5.2.7.0/include % pkg-config --libs allegro-5 allegro_main-5 -L/usr/local/Cellar/allegro/5.2.7.0/lib -lallegro_main -lallegro
Você pode pegar essas opções e digitá-las em seu Makefile, mas normalmente as pessoas usam os back-ticks que "significa executar este programa e substituir por qualquer que seja a saída".
No seu Makefile você tem
CFLAGS = -g -Wall -Wextra `pkg-config --cflags lallegro lallegro_main lallegro_font lallegro_dialog`
Isso está errado porque 'lallegro' não é um nome de pacote, nem os outros. Deveria ser:
CFLAGS = -g -Wall -Wextra `pkg-config --cflags allegro-5 allegro_main-5 allegro_font-5 allegro_dialog-5`
Isso se torna apenas
-I/usr/local/Cellar/allegro/5.2.7.0/include
e você também não precisa de INFLAGS em seu Makefile.
Você também tem
LIBS = -lallegro -lallegro_font -lallegro_main -lncurses -lmysqlclient -lallegro_primitives -lallegro_image -lallegro_font -lallegro_dialog LDFLAGS = -Wl,-rpath,/usr/local/lib
Este é um trabalho para pkg-config!
LIBS = `pkg-config --libs allegro-5 allegro_main-5 allegro_font-5 allegro_dialog-5`
que se torna
-L/usr/local/Cellar/allegro/5.2.7.0/lib -lallegro_main -lallegro_font -lallegro_dialog -lallegro
Na linha do linker, o make tem algumas variáveis pré-definidas para ajudá-lo: LINK.o é o comando correto para vincular arquivos .o. `@` significa o destino (`bicho` neste caso) e `<` significa os arquivos de entrada (`$(OBJECTS)` neste caso)
Juntando eu escreveria seu makefile como
CFLAGS = -g -Wall -Wextra `pkg-config --cflags allegro-5 allegro_main-5 allegro_font-5 allegro_dialog-5` OBJECTS = bicho.o LDLIBS = `pkg-config --libs allegro-5 allegro_main-5 allegro_font-5 allegro_dialog-5` all: bicho bicho: $(OBJECTS) $(LINK.o) -o $@ $< $(LDLIBS) count: wc *.c *.cc *.C *.cpp *.h *.hpp clean: rm -f *.o .PHONY: all .PHONY: count .PHONY: clean