Can I build my PC file (Oracle Pro*c) conditionally inside of my application's make file? - sql

I'm attempting to combine my makefiles so I can simply build once and it will precompile the pc file completely before continuing to build the application. This should be possible but for the life of me I cannot figure it out. Here is my makefile (for redhat 7).
COMPILEDATE = $(shell date)
COMPILE=g++ -std=c++11 -Wall -Wuninitialized -g
OSTYPE = $(shell uname)
LIBDIR=../../lib/
INC=../../include/
FILES=myProcess
OBJS= myProcess.o \
sqlStuff.o
O8P=$(ORACLE_HOME)
O8P=/u01/app/oracle/11.2.0/client_1
ORACLE_HOME=/u01/app/oracle/11.2.0/client_1
PROC_LINES=proc lines=yes code=ANSI_C iname=sqlStuff.pc parse=partial iname=sqlStuff include=. include=$(ORACLE_HOME)/precomp/public include=$(ORACLE_HOME)/rdbms/public include=$(ORACLE_HOME)/rdbms/demo include=$(ORACLE_HOME)/plsql/public include=$(ORACLE_HOME)/network/public
all: $(FILES)
compileInfo.o : FORCE
$(COMPILE) -c compileInfo.cpp -o $# -I$(INC) -DCDATE="\"$(COMPILEDATE)\"" -DBUILD="\"$(LSWBUILD)\""
FORCE :
%.o : %.cpp $(INC)myProcess.h
$(COMPILE) -c $< -o $# -I$(INC) -DCDATE="\"$(COMPILEDATE)\""
sqlStuff.o : sqlStuff.c
gcc -g -Wall -O -c -lclntsh -I. -I$(ORACLE_HOME)/precomp/public -I$(ORACLE_HOME)/rdbms/public -I$(ORACLE_HOME)/rdbms/demo -I$(ORACLE_HOME)/plsql/lib -I$(ORACLE_HOME)/network/lib
sqlStuff.c : sqlStuff.pc
$(PROC_LINES)
myProcess: $(OBJS) $(LIBDIR)libbase.a $(INC)myProcess.h sqlStuff.o
$(COMPILE) -o myProcess$(OBJS) -L$(LIBDIR) -lbase
clean:
rm -f $(FILES)
rm -f sqlStuff
rm -f sqlStuff.c
rm -f sqlStuff.lis
rm -f $(OBJS)
rm -f core
rm -f *.out
rm -f *.log
rm -f *.err
My fault, I didn't explain what the issue was:
I'm compiling in netbeans using this build command: ${MAKE} -f Makefile. The error is PCC-S-02015, unable to open include file on my object that is not being precompiled, sqlStuff.o

Looking at the gcc command under sqlStuff.o : sqlStuff.c, it looks to me that there should be a -o sqlStuff.o flag to tell gcc that the output should be written to sqlStuff.o instead of the default, which is a.out.
Best of luck.

Related

fatal error: gtkmm.h: No such file or directory

i couldn't figureout what's wrong in this code
whatever edit i do, it gives same error every time
all : asio - 1.12.2 src / chat_server client
asio - 1.12.2 :
tar xzf asio - 1.12.2.tar.gz
client : src / client.cpp src / mainwin.cpp src/*.h
$(CXX) $(CXXFLAGS) src/client.cpp src/mainwin.cpp $(GTKFLAGS) -o src/client
GTKLINKFLAGS=$(shell pkg-config --libs gtkmm-3.0)
GTKCOMPILEFLAGS=$(shell pkg-config --cflags gtkmm-3.0)
CXXFLAGS+= -DASIO_STANDALONE -Wall -O0 -g -std=c++11
CPPFLAGS+=-I./include -I./asio-1.12.2/include -I./src ${GTKCOMPILEFLAGS}
LDLIBS+= -lpthread ${GTKLINKFLAGS}
clean:
-rm -rf asio-1.12.2
-rm -f src/client
-rm -f src/chat_server
I can reproduce your error. In:
client : src / client.cpp src / mainwin.cpp src/*.h
$(CXX) $(CXXFLAGS) src/client.cpp src/mainwin.cpp $(GTKFLAGS) -o src/client
You are using $(GTKFLAGS) which is empty. To notice it type: make -n. In your case replace it by $(GTKCOMPILEFLAGS) $(GTKLINKFLAGS) but this is not a nice fix because you should separate your Makefile rules:
one for compiling each cpp file into object file (.o)
and one rule for linking all objects files into your binary.

Building Tensorflow with Bazel: Executing genrule #png_archive//:configure failed

I've been trying to understand why I can't build Tensorflow with Bazel.
I've been following the install instructions from the Tensorflow webpage here.
Here's my output when I build with the command bazel build -c opt --config=cuda --verbose_failures //tensorflow/cc:tutorials_example_trainer
[mcochrane#Matt-PC-Fedora tensorflow]$ bazel build -c opt --config=cuda --verbose_failures //tensorflow/cc:tutorials_example_trainer
INFO: Found 1 target...
INFO: From Executing genrule #png_archive//:configure:
/home/mcochrane/.cache/bazel/_bazel_mcochrane/fd0e4dd3891f9c98b9d8308260aad0f3/tensorflow/external/png_archive/libpng-1.2.53 /home/mcochrane/.cache/bazel/_bazel_mcochrane/fd0e4dd3891f9c98b9d8308260aad0f3/tensorflow
/tmp/tmp.52xPGPoCo8 /home/mcochrane/.cache/bazel/_bazel_mcochrane/fd0e4dd3891f9c98b9d8308260aad0f3/tensorflow/external/png_archive/libpng-1.2.53 /home/mcochrane/.cache/bazel/_bazel_mcochrane/fd0e4dd3891f9c98b9d8308260aad0f3/tensorflow
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/tmp/tmp.52xPGPoCo8':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: /home/mcochrane/.cache/bazel/_bazel_mcochrane/fd0e4dd3891f9c98b9d8308260aad0f3/external/png_archive/BUILD:23:1: Executing genrule #png_archive//:configure failed: bash failed: error executing command
(cd /home/mcochrane/.cache/bazel/_bazel_mcochrane/fd0e4dd3891f9c98b9d8308260aad0f3/tensorflow && \
exec env - \
PATH=/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/home/mcochrane/.local/bin:/home/mcochrane/bin \
/bin/bash -c 'source tools/genrule/genrule-setup.sh; pushd external/png_archive/libpng-1.2.53; workdir=$(mktemp -d -t tmp.XXXXXXXXXX); cp -a * $workdir; pushd $workdir; ./configure --enable-shared=no --with-pic=no; popd; popd; cp $workdir/config.h bazel-out/local_linux-opt/genfiles/external/png_archive/libpng-1.2.53; rm -rf $workdir;'): bash failed: error executing command
(cd /home/mcochrane/.cache/bazel/_bazel_mcochrane/fd0e4dd3891f9c98b9d8308260aad0f3/tensorflow && \
exec env - \
PATH=/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/home/mcochrane/.local/bin:/home/mcochrane/bin \
/bin/bash -c 'source tools/genrule/genrule-setup.sh; pushd external/png_archive/libpng-1.2.53; workdir=$(mktemp -d -t tmp.XXXXXXXXXX); cp -a * $workdir; pushd $workdir; ./configure --enable-shared=no --with-pic=no; popd; popd; cp $workdir/config.h bazel-out/local_linux-opt/genfiles/external/png_archive/libpng-1.2.53; rm -rf $workdir;').
Target //tensorflow/cc:tutorials_example_trainer failed to build
INFO: Elapsed time: 2.229s, Critical Path: 0.71s
It's a bit cryptic. Bash just fails with the following message which doesn't really provide a whole lot of insight.
bash failed: error executing command
(cd /home/mcochrane/.cache/bazel/_bazel_mcochrane/fd0e4dd3891f9c98b9d8308260aad0f3/tensorflow && \
exec env - \
PATH=/usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/home/mcochrane/.local/bin:/home/mcochrane/bin \
/bin/bash -c 'source tools/genrule/genrule-setup.sh; pushd external/png_archive/libpng-1.2.53; workdir=$(mktemp -d -t tmp.XXXXXXXXXX); cp -a * $workdir; pushd $workdir; ./configure --enable-shared=no --with-pic=no; popd; popd; cp $workdir/config.h bazel-out/local_linux-opt/genfiles/external/png_archive/libpng-1.2.53; rm -rf $workdir;').
Has anyone else come across this error when compiling with bazel?
EDIT: extra info
OS is Fedora23 (kernel 4.2.6-300.fc23)
gcc version is 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC)
[mcochrane#Matt-PC-Fedora tensorflow]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC)
ldd version is: (GNU libc) 2.22

makefile, size of an executable, static/dynamic

I have a makefile, for a C project with 2 sub-C-files and I can create two exe, one static and one dynamic.
But the static is lighter in space than the dynamic!
The programs can be launched and seems to be the sames
Is it normal?
Thank you very much, I have an exam in 2 days and I hope I will fix that problem :)
Simon
CC = gcc
CFLAGS = -Wall
CFLAGS2 = -shared
CFLAGS3 = -fPIC
LIB_U_CAM_TTL = -l_projet_vision_u_cam_ttl
LIB_SERIAL_LINUX = -l_projet_vision_serial_linux
CHEMIN = -L/usr/local/lib
lib_projet_vision_serial_linux.so: serial_linux.o
$(CC) $(CFLAGS2) $^ -o $#
lib_projet_vision_u_cam_ttl.so: u_cam_ttl.o
$(CC) $(CFLAGS2) $^ -o $#
lib_projet_vision_serial_linux.a : serial_linux.o
ar -rv $# $^
lib_projet_vision_u_cam_ttl.a : u_cam_ttl.o
ar -rv $# $^
projet_vision_dynamic: main_vision.c install
$(CC) $(CFLAGS3) $^ $(CHEMIN) $(LIB_SERIAL_LINUX) $(LIB_U_CAM_TTL) -o $#
projet_vision_static: main_vision.c install
$(CC) $^ $(CHEMIN) $(LIB_SERIAL_LINUX) $(LIB_U_CAM_TTL) -o $#
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $#
install: lib_projet_vision_serial_linux.so lib_projet_vision_serial_linux.a lib_projet_vision_u_cam_ttl.so lib_projet_vision_u_cam_ttl.a
sudo cp -f *.h /usr/local/include/
sudo cp -f *.so /usr/local/lib/
sudo cp -f *.a /usr/local/lib/
sudo cp projet_vision_dynamic /usr/bin/
sudo cp projet_vision_static /usr/bin/
sudo ldconfig
uninstall: clean
sudo rm -f /usr/local/include/serial_linux.h
sudo rm -f /usr/local/include/u_cam_ttl.h
sudo rm -f /usr/local/lib/lib_projet_vision_serial_linux.so
sudo rm -f /usr/local/lib/lib_projet_vision_u_cam_ttl.so
sudo rm -f /usr/local/lib/lib_projet_vision_u_cam_ttl.a
sudo rm -f /usr/local/lib/lib_projet_vison_serial_linux.a
sudo ldconfig
clean:
rm -f *.o *~ *.so *.a
rm -f projet_vision_static projet_vision_dynamic

Makefile rule using the automatic variable $^ without dependencies

I learnt from the GNU Make manual that the sign $^ is an automatic variable which represents the names of all the prerequisites. However I fell upon a makefile like this one:
SVR_OBJECT_FILES = server.o\
server_func.o
CLT_OBJECT_FILES = client.o
CFLAGS = -Wall -Werror -W
CC = gcc
all: client/client server/serveur
client/client: $(CLT_OBJECT_FILES)
server/serveur: $(SVR_OBJECT_FILES)
client/client server/serveur:
#mkdir -p $(dir $#)
$(CC) $(CFLAGS) $^ -o $#
%.o: %.c
$(CC) -c $<
clean:
rm -f client/client server/serveur *.o
Which works fine so my question is :
How can the command below can link the right object files while the $^ variable is refering no preprerequisites at all. (the rule has no prerequisites)
$(CC) $(CFLAGS) $^ -o $#
$^ contains all the prerequisites of the target, not just the ones that are mentioned with the rule itself. The same file can appear as a target several times in rules with no commands:
sometarget: dependency1
…
sometarget: dependency2
assemble -o $# $^
…
sometarget: dependency3
The dependencies of sometarget are dependency1, dependency2 and dependency3, and when the assemble command is invoked by make sometarget, it will receive all three as arguments.
Here, $^ will contain all $(CLT_OBJECT_FILES) or $(SRV_OBJECT_FILES) depending on which target the command is executed for.

How to write a shell script to compile multiple embedded sql in C files (.sqc)?

I have written 3 .sqc files i.e. embedded sql in host language C. I need to make a (Unix) shell script to simply compile all 3 sqc files in a row. How can I do that? Right now, I can individually run each .sqc file using a Makefile that basically converts the .sqc file to a c file and then compiles it. Can I make 3 individual Makefiles and run all of them through a shell script? If so, then how? Can I make one Makefile that can compile all 3 .sqc independently and compile them thereafter through a shell script? If so, then how? Any other options?
Here is the Makefile that can only compile a single .sqc file:
NAME=sample
DB2PATH = /sqllib
CC=gcc
CFLAGS=-I$(DB2PATH)/include
LIBS=-L$(DB2PATH)/lib -R$(DB2PATH)/lib -ldb2
all: $(NAME)
$(NAME): $(NAME).sqc util.o
db2 connect to sampleDB
db2 prep $(NAME).sqc bindfile
db2 bind $(NAME).bnd
db2 connect reset
$(CC) $(CFLAGS) -c $(NAME).c
$(CC) $(CFLAGS) -o $(NAME) $(NAME).o util.o $(LIBS)
clean:
rm -f $(NAME) $(NAME).c $(NAME).o $(NAME).bnd
util.o : util.c
$(CC) -c util.c $(CFLAGS)
A possible (Unix) shell script and Makefile example would suffice to help.
Thank you.
This Makefile should do all three in one step, just type "make". Note that you'll have to change the second line to reflect the names of your real .sqc files.
Also note that I'm not familiar with sqc and I haven't tested this, I'm just working from your Makefile.
# THIS IS THE ONLY LINE YOU'LL HAVE TO CHANGE:
NAMES = file1 file2 file3
DB2PATH = /sqllib
CC=gcc
CFLAGS=-I$(DB2PATH)/include
LIBS=-L$(DB2PATH)/lib -R$(DB2PATH)/lib -ldb2
all: $(NAMES)
# This will convert .sqc into .c
%.c: %.sqc
db2 connect to sampleDB
db2 prep $< bindfile
db2 bind $*.bnd
db2 connect reset
# This will compile .c into .o, whether it's fileN.c or util.c
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $#
# This will link fileN.o and util.o into fileN
$(NAMES): % : %.o util.o
$(CC) $(CFLAGS) -o $# $^ $(LIBS)
# This is just to assure Make that that isn't really a file called "clean"
.PHONY: clean
clean:
rm -f $(NAMES) $(NAMES:=.c) $(NAMES:=.o) $(NAMES:=.bnd)
DB2PATH = /sqllib
CC=gcc
CFLAGS=-I$(DB2PATH)/include
LIBS=-L$(DB2PATH)/lib -R$(DB2PATH)/lib -ldb2
all: $(NAME)
$(NAME): $(NAME).sqc util.o
db2 connect to sampleDB
db2 prep $(NAME).sqc bindfile
db2 bind $(NAME).bnd
db2 connect reset
$(CC) $(CFLAGS) -c $(NAME).c
$(CC) $(CFLAGS) -o $(NAME) $(NAME).o util.o $(LIBS)
clean:
rm -f $(NAME) $(NAME).c $(NAME).o $(NAME).bnd
util.o : util.c
$(CC) -c util.c $(CFLAGS)
suppose you have three files: file1.sqc file2.sqc file3.sqc, and your makefile is saved as mksqc.mk
Script:
make -f mksqc.mk NAME=file1
make -f mksqc.mk NAME=file2
make -f mksqc.mk NAME=file3