When I compile my makefile, I encounter this problem:
gcc parser.tab.o -o parser.tab
/usr/lib/../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
parser.tab.o: In function `yyparse':
parser.tab.c:(.text+0x2c3): undefined reference to `yylex'
parser.tab.c:(.text+0x3f5): undefined reference to `execute'
parser.tab.c:(.text+0x82b): undefined reference to `yyerror'
parser.tab.c:(.text+0x947): undefined reference to `yyerror'
collect2: ld returned 1 exit status
make: *** [parser.tab] Error 1
Here is my make file:
CC = gcc
CFLAGS = -lreadline
PROGS = d8sh parser.tab executor lexer
all: $(PROGS)
clean:
rm -f *.o $(PROGS) *.tmp
d8sh: d8sh.o
d8sh.o: executor.h lexer.h
executor.o: command.h
lexer.o: parser.tab.h
parser.tab.o: command.h
Only d8sh.c has a main function. Can anyone figure out what the problem is?
Related
I have a c program with a makefile that works perfectly on macos but when i try yo run it on linux it gives me a bunch of errors
gcc ./libft/libft.a srcs/main.o -o push_swap
/usr/bin/ld: srcs/main.o: in function `sa':
main.c:(.text+0x97): undefined reference to `ft_putstr'
/usr/bin/ld: srcs/main.o: in function `sb':
main.c:(.text+0x149): undefined reference to `ft_putstr'
/usr/bin/ld: srcs/main.o: in function `ss':
main.c:(.text+0x1eb): undefined reference to `ft_putstr'
/usr/bin/ld: srcs/main.o: in function `pa':
main.c:(.text+0x236): undefined reference to `ft_putstr'
/usr/bin/ld: srcs/main.o: in function `pb':
main.c:(.text+0x2df): undefined reference to `ft_putstr'
/usr/bin/ld: main.c:(.text+0x327): undefined reference to `ft_putnbr_fd'
/usr/bin/ld: srcs/main.o: in function `printstack':
main.c:(.text+0x3b3): undefined reference to `ft_putnbr_fd'
/usr/bin/ld: main.c:(.text+0x3bd): undefined reference to `ft_putchar'
/usr/bin/ld: main.c:(.text+0x3df): undefined reference to `ft_putnbr_fd'
/usr/bin/ld: main.c:(.text+0x3e9): undefined reference to `ft_putchar'
/usr/bin/ld: main.c:(.text+0x404): undefined reference to `ft_putstr'
/usr/bin/ld: main.c:(.text+0x413): undefined reference to `ft_putstr'
/usr/bin/ld: srcs/main.o: in function `main':
main.c:(.text+0x4a9): undefined reference to `ft_atoi'
collect2: error: ld returned 1 exit status
make: *** [Makefile:23: push_swap] Error 1
I believe the cause is the Makefile because it can't find the function that the makefile is suppose to compile too but im not sure about that.
Anyways here is my makefile:
NAME = push_swap
LIBFT_PATH = libft
LIBFT = libft.a
SRC_FILES = main.c
SRC_DIR = srcs/
SRC = ${addprefix ${SRC_DIR}, ${SRC_FILES}}
OBJ = ${SRC:.c=.o}
CC = gcc
CFLAGS = -Wall -Wextra -Werror -pg -g
AR = ar -rcs
%.o: %.c
${CC} -c -Imlx -c $< -o $#
all: ${NAME}
libft:
#MAKE -sC ${LIBFT_PATH}
${NAME}: libft ${OBJ}
${CC} ${LIBFT_PATH}/${LIBFT} ${OBJ} -o ${NAME}
clean:
rm -f ${OBJ}
${MAKE} -C ${LIBFT_PATH} clean
fclean: clean
rm -f ${NAME}
${MAKE} -C ${LIBFT_PATH} fclean
re: fclean all
.PHONY: all clean flcean re
I have a sample code temp.c:
#include "win.h"
win.h is in /home/me/Documents/Code/libs/TUI/win.h and has all the declared functions
which functions are defined in some files in /home/me/Documents/Code/libs/TUI/win/[lots of files].c which every file starts with
#include "../win.h"
//functions
So while using gcc -I /home/me/Documents/Code/libs/TUI /home/me/Documents/Code/temp.c -o /home/me/Documents/Code/temp, gcc returns every function used in temp.c declared in win.h as undefined
Exact output:
gcc -g -I/home/me/Documents/Code/libs/TUI /home/me/Documents/Code/temp.c -o /home/pk/Documents/Code/temp
/usr/bin/ld: /tmp/cc4berEn.o: in function `main':
/home/me/Documents/Code/temp.c:8: undefined reference to `innit'
/usr/bin/ld: /home/me/Documents/Code/temp.c:11: undefined reference to `newTable'
/usr/bin/ld: /home/me/Documents/Code/temp.c:13: undefined reference to `tableSetHeaders'
/usr/bin/ld: /home/me/Documents/Code/temp.c:35: undefined reference to `tableAppendRow'
/usr/bin/ld: /home/me/Documents/Code/temp.c:45: undefined reference to `printTable'
collect2: error: ld returned 1 exit status
notes
Using -I /home/me/Documents/Code/libs/TUI/win.h returns fatal error: win.h: No such file or directory 3 | #include "win.h"
/home/me/Documents/Code/libs/TUI is a folder
Writing every source file's name is not an option
Already tried this
-g for debug
I'm trying to build xulrunner version 2.0 (sources downloaded from mozilla ftp site) but I keep getting some undefined references when trying to create libxul.so. I tried version 10.0 but same results.
I'm building on Archlinux, but I also get the same error on Ubuntu from the VM I downloaded from mozilla site.
Prior to build xulrunner, some modifications were required in order to build:
https://hg.mozilla.org/mozilla-central/rev/effb4811409b
https://hg.mozilla.org/mozilla-central/rev/87a5ed480992
needed to create an empty /usr/include/curl/types.h file
file security/coreconf/Linux3.16.mk does not exist : copy Linux2.6.mk to Linux3.16.mk
The .mozconfig I'm using:
mk_add_options AUTOCONF=autoconf-2.13
mk_add_options PYTHON=/usr/bin/python2
mk_add_options MOZ_CO_PROJECT=xulrunner
mk_add_options MOZ_OBJDIR=#topsrcdir#/obj-xulrunner
ac_add_options --enable-application=xulrunner
ac_add_options --disable-javaxpcom
After about 30 minutes, I get these errors when trying to build libxul.so:
...
rm -f libxul.so
c++ -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -pedantic -Wno-long-long -fno-strict-aliasing -fshort-wchar -pthread -pipe -DNDEBUG -DTRIMMED -Os -freorder-blocks -fomit-frame-pointer -fPIC -shared -Wl,-z,defs -Wl,-h,libxul.so -o libxul.so nsStaticXULComponents.o nsUnicharUtils.o nsBidiUtils.o nsRDFResource.o -lpthread -Wl,-rpath-link,/disk2/mozilla/buildtmp/obj-xulrunner/dist/bin -Wl,-rpath-link,/usr/local/lib -Wl,--whole-archive ../../embedding/browser/gtk/src/libgtkembedmoz.a ../../toolkit/xre/libxulapp_s.a ../../staticlib/components/libnecko.a ../../staticlib/components/libuconv.a ../../staticlib/components/libi18n.a ../../staticlib/components/libchardet.a ../../staticlib/components/libjar50.a ../../staticlib/components/libstartupcache.a ../../staticlib/components/libpref.a ../../staticlib/components/libhtmlpars.a ../../staticlib/components/libimglib2.a ../../staticlib/components/libgklayout.a ../../staticlib/components/libdocshell.a ../../staticlib/components/libembedcomponents.a ../../staticlib/components/libwebbrwsr.a ../../staticlib/components/libnsappshell.a ../../staticlib/components/libtxmgr.a ../../staticlib/components/libcommandlines.a ../../staticlib/components/libtoolkitcomps.a ../../staticlib/components/libpipboot.a ../../staticlib/components/libpipnss.a ../../staticlib/components/libappcomps.a ../../staticlib/components/libjetpack_s.a ../../staticlib/components/libjsctypes.a ../../staticlib/components/libjsperf.a ../../staticlib/components/libgkplugin.a ../../staticlib/components/libunixproxy.a ../../staticlib/components/libjsd.a ../../staticlib/components/libautoconfig.a ../../staticlib/components/libauth.a ../../staticlib/components/libcookie.a ../../staticlib/components/libpermissions.a ../../staticlib/components/libuniversalchardet.a ../../staticlib/components/libcomposer.a ../../staticlib/components/librdf.a ../../staticlib/components/libwindowds.a ../../staticlib/components/libfileview.a ../../staticlib/components/libstoragecomps.a ../../staticlib/components/libplaces.a ../../staticlib/components/libtkautocomplete.a ../../staticlib/components/libsatchel.a ../../staticlib/components/libpippki.a ../../staticlib/components/libwidget_gtk2.a ../../staticlib/components/libsystem-pref.a ../../staticlib/components/libimgicon.a ../../staticlib/components/libgkgfxthebes.a ../../staticlib/components/libaccessibility.a ../../staticlib/components/libremoteservice.a ../../staticlib/components/libspellchecker.a ../../staticlib/components/libzipwriter.a ../../staticlib/components/libservices-crypto.a ../../staticlib/libjsipc_s.a ../../staticlib/libdomipc_s.a ../../staticlib/libdomplugins_s.a ../../staticlib/libmozipc_s.a ../../staticlib/libmozipdlgen_s.a ../../staticlib/libipcshell_s.a ../../staticlib/libgfxipc_s.a ../../staticlib/libxpcom_core.a ../../staticlib/libucvutil_s.a ../../staticlib/libgkgfx.a ../../staticlib/libchromium_s.a ../../staticlib/libmozreg_s.a ../../staticlib/libmorkreader_s.a ../../staticlib/libgtkxtbin.a ../../staticlib/libthebes.a ../../staticlib/libycbcr.a ../../staticlib/libangle.a -Wl,--no-whole-archive -L../../dist/lib -lmozsqlite3 -L../../dist/bin -L../../dist/lib -L../../jpeg -lmozjpeg -L../../modules/libimg/png -lmozpng -L../../gfx/qcms -lmozqcms -L/disk2/mozilla/buildtmp/obj-xulrunner/dist/bin -ljs_static -L../../dist/bin -L../../dist/lib -lcrmf -lsmime3 -lssl3 -lnss3 -lnssutil3 -L../../gfx/cairo/cairo/src -lmozcairo -L../../gfx/cairo/libpixman/src -lmozlibpixman -lXrender -lfreetype -lfontconfig ../../gfx/harfbuzz/src/libmozharfbuzz.a ../../gfx/ots/src/libmozots.a -L../../modules/zlib/src -lmozz -lasound -lrt -L../../dist/bin -L../../dist/lib -L/disk2/mozilla/buildtmp/obj-xulrunner/dist/lib -lplds4 -lplc4 -lnspr4 -lpthread -ldl -L../../dist/lib -lmozalloc -ldbus-1 -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -lX11 -lXext -lpangoft2-1.0 -lfontconfig -lfreetype -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lgtk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lfontconfig -lfreetype -lgdk-x11-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lXt -lgthread-2.0 -lfreetype -lz -lbz2 -lpng16 -lharfbuzz -ldl -lrt
../../staticlib/libthebes.a(gfxPangoFonts.o): In function `gfxDownloadedFcFontEntry::~gfxDownloadedFcFontEntry()':
gfxPangoFonts.cpp:(.text+0x1a63): undefined reference to `FT_Done_Face'
../../staticlib/libthebes.a(gfxPangoFonts.o): In function `gfxPangoFontGroup::NewFontEntry(gfxProxyFontEntry const&, unsigned char const*, unsigned int)':
gfxPangoFonts.cpp:(.text+0x3a61): undefined reference to `FT_New_Memory_Face'
../../staticlib/libthebes.a(gfxFT2Utils.o): In function `gfxFT2LockedFace::GetGlyph(unsigned int)':
gfxFT2Utils.cpp:(.text+0x6b): undefined reference to `FT_Select_Charmap'
../../staticlib/libthebes.a(gfxFT2Utils.o): In function `gfxFT2LockedFace::GetMetrics(gfxFont::Metrics*, unsigned int*)':
gfxFT2Utils.cpp:(.text+0x216): undefined reference to `FT_Get_Sfnt_Table'
gfxFT2Utils.cpp:(.text+0x450): undefined reference to `FT_Get_Sfnt_Table'
../../staticlib/libthebes.a(gfxFT2Utils.o): In function `gfxFT2LockedFace::FindCharVariantFunction()':
gfxFT2Utils.cpp:(.text+0x78e): undefined reference to `FT_Library_Version'
../../staticlib/libthebes.a(gfxFT2Utils.o): In function `gfxFT2LockedFace::GetUVSGlyph(unsigned int, unsigned int)':
gfxFT2Utils.cpp:(.text+0x84c): undefined reference to `FT_Select_Charmap'
../../staticlib/libthebes.a(gfxFT2Utils.o): In function `gfxFT2LockedFace::GetFontTable(unsigned int, FallibleTArray<unsigned char>&)':
gfxFT2Utils.cpp:(.text+0x8ba): undefined reference to `FT_Load_Sfnt_Table'
gfxFT2Utils.cpp:(.text+0x951): undefined reference to `FT_Load_Sfnt_Table'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_unscaled_font_map_lock':
cairo-ft-font.c:(.text+0x7c): undefined reference to `FT_Init_FreeType'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_unscaled_font_set_scale':
cairo-ft-font.c:(.text+0x347): undefined reference to `FT_Set_Transform'
cairo-ft-font.c:(.text+0x3af): undefined reference to `FT_Set_Char_Size'
cairo-ft-font.c:(.text+0x445): undefined reference to `FT_Set_Char_Size'
cairo-ft-font.c:(.text+0x462): undefined reference to `FT_Set_Pixel_Sizes'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_scaled_glyph_vertical_layout_bearing_fix':
cairo-ft-font.c:(.text+0xa25): undefined reference to `FT_Vector_Transform'
cairo-ft-font.c:(.text+0xa3a): undefined reference to `FT_Outline_Translate'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_unscaled_font_map_pluck_entry':
cairo-ft-font.c:(.text+0x11e9): undefined reference to `FT_Done_Face'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_unscaled_font_destroy':
cairo-ft-font.c:(.text+0x16ba): undefined reference to `FT_Done_Face'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_unscaled_font_lock_face':
cairo-ft-font.c:(.text+0x1aee): undefined reference to `FT_New_Face'
cairo-ft-font.c:(.text+0x1b11): undefined reference to `FT_Done_Face'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_index_to_ucs4':
cairo-ft-font.c:(.text+0x1b8c): undefined reference to `FT_Get_First_Char'
cairo-ft-font.c:(.text+0x1baf): undefined reference to `FT_Get_Next_Char'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_scaled_glyph_init':
cairo-ft-font.c:(.text+0x1ce6): undefined reference to `FT_Load_Glyph'
cairo-ft-font.c:(.text+0x1e9a): undefined reference to `FT_Outline_Transform'
cairo-ft-font.c:(.text+0x1eac): undefined reference to `FT_Outline_Decompose'
cairo-ft-font.c:(.text+0x2012): undefined reference to `FT_Render_Glyph'
cairo-ft-font.c:(.text+0x20ac): undefined reference to `FT_Load_Glyph'
cairo-ft-font.c:(.text+0x2114): undefined reference to `FT_GlyphSlot_Embolden'
cairo-ft-font.c:(.text+0x21f3): undefined reference to `FT_Outline_Get_CBox'
cairo-ft-font.c:(.text+0x291e): undefined reference to `FT_Outline_Transform'
cairo-ft-font.c:(.text+0x29b1): undefined reference to `FT_Outline_Translate'
cairo-ft-font.c:(.text+0x29d3): undefined reference to `FT_Outline_Get_Bitmap'
cairo-ft-font.c:(.text+0x2be4): undefined reference to `FT_GlyphSlot_Embolden'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_load_truetype_table':
cairo-ft-font.c:(.text+0x2d70): undefined reference to `FT_Load_Sfnt_Table'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-ft-font.o): In function `_cairo_ft_font_reset_static_data':
cairo-ft-font.c:(.text+0x358f): undefined reference to `FT_Done_FreeType'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-type1-subset.o): In function `cairo_type1_font_subset_get_glyph_names_and_widths':
cairo-type1-subset.c:(.text+0x379): undefined reference to `FT_Load_Glyph'
cairo-type1-subset.c:(.text+0x3b1): undefined reference to `FT_Get_Glyph_Name'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-type1-subset.o): In function `_cairo_type1_subset_init':
cairo-type1-subset.c:(.text+0xa8e): undefined reference to `FT_Get_PS_Font_Info'
../../gfx/cairo/cairo/src/libmozcairo.a(cairo-type1-subset.o): In function `_cairo_type1_scaled_font_is_type1':
cairo-type1-subset.c:(.text+0x1924): undefined reference to `FT_Get_PS_Font_Info'
/usr/bin/ld: libxul.so: hidden symbol `FT_Outline_Get_Bitmap' isn't defined
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
/disk2/mozilla/sources/10.0/mozilla-2.0/config/rules.mk:1291: recipe for target 'libxul.so' failed
make[4]: *** [libxul.so] Error 1
make[4]: Leaving directory '/disk2/mozilla/buildtmp/obj-xulrunner/toolkit/library'
/disk2/mozilla/sources/10.0/mozilla-2.0/config/rules.mk:783: recipe for target 'libs_tier_platform' failed
make[3]: *** [libs_tier_platform] Error 2
make[3]: Leaving directory '/disk2/mozilla/buildtmp/obj-xulrunner'
/disk2/mozilla/sources/10.0/mozilla-2.0/config/rules.mk:793: recipe for target 'tier_platform' failed
make[2]: *** [tier_platform] Error 2
make[2]: Leaving directory '/disk2/mozilla/buildtmp/obj-xulrunner'
/disk2/mozilla/sources/10.0/mozilla-2.0/config/rules.mk:746: recipe for target 'default' failed
make[1]: *** [default] Error 2
make[1]: Leaving directory '/disk2/mozilla/buildtmp/obj-xulrunner'
client.mk:345: recipe for target 'build' failed
make: *** [build] Error 2
The command line used to create libxul.so does contains the '-lfreetype', and when I look for FT_Done_Face function into libfreetype.so, it is present :
[dev400t#arch mozilla-2.0]$ nm --dynamic /usr/lib/libfreetype.so | grep FT_Done_Face
000000000001b300 T FT_Done_Face
I did add the "-Wl,-t" option to the command line to make sure libfreetype.so could be found: it is found.
What am I missing?
Your freetype2 version is >= 2.5.1. It contains this change http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=fae382076409db198dfbff36ac4cbb97b05b30a1, which is backwards-incompatible as far as Firefox is concerned.
You need to backport the fix from this bug to your source tree: https://bugzilla.mozilla.org/show_bug.cgi?id=944454 or downgrade your libfreetype2.
Firefox sources as of version 26 and later (including 24 ESR) already contain the fix.
Trying to compile these files with gcc under Makefile rules. Running gcc / make on cygwin.
Here's the makefile:
CC = gcc
CFLAGS = -g -O2 -Wall -std=c99
OBJECTS = simulation.o element.o
simulation.exe : $(OBJECTS)
$(CC) $(CFLAGS) -o simulation.exe $(OBJECTS)
simulation.o : file_priorite.o element.o
$(CC) $(CFLAGS) -c simulation.c
file_priorite.o: file_priorite.h element.o
$(CC) $(CFLAGS) -c file_priorite.c
element.o : element.h
$(CC) $(CFLAGS) -c element.c
clean:
rm -f *.o simulation.exe
And getting these errors:
CLEAN SUCCESSFUL (total time: 52ms)
gcc -g -O2 -Wall -std=c99 -c element.c
gcc -g -O2 -Wall -std=c99 -c simulation.c
gcc -g -O2 -Wall -std=c99 -o simulation.exe simulation.o element.o
simulation.o: In function `main':
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:11: undefined reference to `construire'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:11:(.text.startup+0x17): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `construire'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:20: undefined reference to `ajouter_element'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:20:(.text.startup+0x69): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `ajouter_element'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:23: undefined reference to `consommer_element'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:23:(.text.startup+0x76): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `consommer_element'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:23: undefined reference to `consommer_element'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:23:(.text.startup+0x86): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `consommer_element'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:25: undefined reference to `obtenir_taille'
/cygdrive/d/Dropbox/UQAM AUTOMNE 2014/INF7330/lab10/lab10/simulation.c:25:(.text.startup+0x96): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `obtenir_taille'
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'simulation.exe' failed
make: *** [simulation.exe] Error 1
The problematic functions are all implemented in file_priorite.c.
Any idea?
You need to have
OBJECTS = simulation.o element.o file_priorite.o
Notice that your build log doesn't include file_priorite in any form - that means you're not building/linking against it. Add file_priorite.o to your OBJECTS line.
#include<stdio.h>
#include "flite.h"
cst_voice *register_cmu_us_kal();
int main()
{
cst_voice *v;
cst_wave *w;
char *text = "Hello world programming";
//Initialising the flite variables used
flite_init();
w = new_wave();
v = register_cmu_us_kal(NULL);
flite_text_to_speech(text,v,"hello_wave");
if(cst_wave_load_riff(w,"hello_wave")!=CST_OK_FORMAT){
printf("\nCompare_wave:Can read file or wrong format!\n");
}
else{
play_wave(w);
}
return 0;
}
Makefile
all:compile \
./compile
compile:eg1.o
gcc -o $# eg1.o
eg1.o:eg1.c $(LIBS_DIR) $(INC_DIR) $(LIBS)
gcc -c $<
LIBS_DIR = -L /home/b/flite-1.4-release/build/i386-linux-gnu/lib
INC_DIR = -I /home/b/flite-1.4-relase/include
LIBS = -lflite_cmu_us_slt -lflite -lflite_cmulex -lflite_cmu_time_awb -lflite_cmu_us_kal16 -lflite_cmu_us_kal -lflite_cmu_usenglish
INCLUDE:
clean:
rm -f *.o
I tried by giving he library and header file paths as LIBS_DIR = ../build/i386-linux-gnu/lib and INC_DIR = ../include
I tried the folowing c program by including a third party library. This program an a makefile is located in b\flite-1.4-release\Learnin_though_example folder. Th flite libraries are located in b\flite-1.4-release\build\i386-linux-gnu\lib and the header files are in b\flite-1.4-release\include .
I assume that i have given the makefile th correct path to search for the files. But its not identifyin it and i'm gettin an error as,
make clean all
rm -f *.o
gcc -c eg1.c
eg1.c:2:19: error: flite.h: No such file or directory
eg1.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
eg1.c: In function ‘main’:
eg1.c:6: error: ‘cst_voice’ undeclared (first use in this function)
eg1.c:6: error: (Each undeclared identifier is reported only once
eg1.c:6: error: for each function it appears in.)
eg1.c:6: error: ‘v’ undeclared (first use in this function)
eg1.c:7: error: ‘cst_wave’ undeclared (first use in this function)
eg1.c:7: error: ‘w’ undeclared (first use in this function)
eg1.c:17: error: ‘CST_OK_FORMAT’ undeclared (first use in this function)
make: *** [eg1.o] Error 1
Please help me understand what is the mistake i'm doing
EDITED:
I modiied th makefile as per matt's guidance:
all:compile
compile:eg1.o
gcc $(INC_DIR) $(LIB_DIR) -o $# $^ $(LIBS)
eg1.o:eg1.c
gcc $(INC_DIR) -o $# -c $^
LIBS_DIR = -L../build/i386-linux-gnu/lib
INC_DIR = -I../include
LIBS = -lflite -lflite_cmulex -lflite_cmu_time_awb -lflite_cmu_us_kal16 -lflite_cmu_us_kal -lflite_cmu_usenglish -lflite_cmu_us_slt
clean:
rm -f *.o
but i'm getting ifferent error whn compiled with the command "make clean all" as,
rm -f *.o
gcc -I../include -o eg1.o -c eg1.c
gcc -I../include -o compile eg1.o -lflite -lflite_cmulex -lflite_cmu_time_awb -lflite_cmu_us_kal16 -lflite_cmu_us_kal -lflite_cmu_usenglish -lflite_cmu_us_slt
/usr/bin/ld: cannot find -lflite
collect2: ld returned 1 exit status
make: *** [compile] Error 1
EDITED:
rm -f *.o
gcc -I../include -o eg1.o -c eg1.c
gcc -I../include -L../build/i386-linux-gnu/lib -o compile eg1.o -lflite -lflite_cmulex -lflite_cmu_time_awb -lflite_cmu_us_kal16 -lflite_cmu_us_kal -lflite_usenglish -lflite_cmu_us_slt -lflite_cmu_us_rms
../build/i386-linux-gnu/lib/libflite.so: undefined reference to `sin'
../build/i386-linux-gnu/lib/libflite.so: undefined reference to `exp'
../build/i386-linux-gnu/lib/libflite.so: undefined reference to `sqrt'
../build/i386-linux-gnu/lib/libflite.so: undefined reference to `log'
../build/i386-linux-gnu/lib/libflite.so: undefined reference to `fmod'
../build/i386-linux-gnu/lib/libflite.so: undefined reference to `pow'
Your makefile is, I'm afraid to say, completely broken.
The basic Makefile syntax is:
target: pre-requisite(s)
<tab>Stuff to do to build target from pre-reqs (if required)
So this is wrong, eg1.o can't be a pre-requisite for building itself.
compile:eg1.o
gcc -o eg1.o
You should have:
eg1.o: eg1.c
gcc $(INC_DIR) -o $# -c $^
($# is the target, $^ all the pre-reqs.)
Then you can:
myexe: eg1.o
gcc $(INC_DIR) $(LIBS_DIR) -o $# $^ $(LIBS)
This will produce myexe from eg1.o. And your all rule should be all: myexe, with no recipe (no commands), and at the top as you have it.
Then you've got your include directories and library directories mixed up. -I is for include paths, -L for library paths.
Place your variable definitions before the rules, that's more common/usual. And don't put a space between -L/-I and the path that follows it.
The include directories to search is specified by -I flag, not -L.
Change:
LIBS_DIR = -I /home/b/flite-1.4-release/build/i386-linux-gnu/lib
INC_DIR = -L /home/b/flite-1.4-relase/include
to:
LIBS_DIR = -L /home/b/flite-1.4-release/build/i386-linux-gnu/lib
INC_DIR = -I /home/b/flite-1.4-relase/include