Programming :: 'makefile' \ Errors Are Mainly Due To Multiple Declarations Of The Functions?
Nov 24, 2010This is the makefile....
Code:
animesh:main.o input.o bsort.o output.o
gcc -o animesh main.o input.o bsort.o output.o
[code]....
This is the makefile....
Code:
animesh:main.o input.o bsort.o output.o
gcc -o animesh main.o input.o bsort.o output.o
[code]....
As part of an assignment, our class was given a small set of c++ classes which are compiled using a makefile. As part of the assignment, I have created a namespace and saved in it a .cpp file. The functions, constants and typedefs from the namespace are now used in one of the original files, and so I added an <#include MyFile.cpp> to the file I modified, in addition to a using MyNamespace;
When I try to use the original makefile, the compiler gives a lot of errors about multiple definitions of every function in the namespace. What do I need to do to resolve this? Do I need to change the makefile or one of the files themselves? I am new to Linux programming and makesfiles.
I have this project which I've been working on essentially nonstop for the past three days and due to work I am running low on time. I'm new to Linux/Unix and my Teacher has assigned us a scripting project, due for Monday. I have All the functions for the project in a separate file which run as a daemon process when I log in. It has no syntax errors but my Script can not run the functions (I'm not sure where they go before or after the body) and I have one function I'd like you guys to take a look at. It has a Second menu leading to a case statement but it does not run after the Search. I'm Kinda tired of looking at the CLI but I have to finish this.
phoneEdi() {
directory=~/phonepro/directory
loop="y"
clear
tput cup 4 4; echo "Record Editor" .....
I am working for a product which was evolved over a decade. There I have some combination of C style coding and C++ coding in same libraries. I am landing on some instances where C style function is expecting forward declarations for some other function for which I can not declare (due to design and architecture). Is there any g++ compiler option that directs the g++ to look whole preprocessed file (because definition is there down in the preprocessed file) than only forward in the preprocessed file. All these years this code is working as we are using CC compiler and that looks entire preprocessed file than only in the forward direction.
<Sample Code
Header1.h file
Function1()
{
[code]....
if I can not include Header2.h first then Header1.h. I have to include Header1.h and Header2.h because on the design hierarchy in this product. Also the function definitions are in header files as they are either template functions or functions expanded through macros.
Is it possible to define functions within other functions in C++? I know it is the case in other languages.
View 2 Replies View RelatedI want to install pgplot on ubuntu 9.10 but I have some errors after editing makefile in line 880
replaced "pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h" by
"pndriv.o : /usr/local/include/png.h /usr/local/include/pngconf.h /usr/local/include/zlib.h /usr/local/include/zconf.h"
and running code "make" I get this error :
No rule to make target `/usr/local/include/png.h', needed by `pndriv.o'. Stop.
also I tried to uncomment this line got another error :
make: *** [pndriv.o] Error 1
and also replace "pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h" by "pndrive.o : "
what should I do ?
How to compile single file in Linux environment using gcc. Now i dont know how to use make file to compile multiple file.
View 5 Replies View RelatedI'm trying to use "netlink" to get ip address of a Linux box. But the linux/types.h included from "linux/rtnetlink.h" introduced many conflicting type declarations with "sys/types.h".
#include <rtnetlink.h>
#include <sys/types.h>
#include <sys/socket.h>
int main (int argc, char *argv[])
{
return 0;
}
The program will demonstrate such type conflicts.
I'm calling a function defined in "uart.c" from "main.c"
But on "make" using cygwin bash, it's giving an error:"Unreferenced function"...
Pls help me to overcome this problem.
If i'm putting the definition of that function in "main.c" itself, its working.
So pls tell me how to write the make file for it?
I need help as I am not proficient with Linux C++ Programming. There are two parts which I need to do in the coding provided below.
1. Produce the program so it can output the word "Hey there!" and wait two minute and print the word "See you later!".
2. Produce the program that will output the text "Cool" every 20 seconds by setting a periodic task.
Quote:
#include <linux/kernel.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
int init_module(void)
{
printk("Hey there!
[Code]...
I just downloaded slackware 13.1(x86) and i'm trying to compile ndiswrapper-1.56 using the slackbuild from slackbuils.org and i'm getting this error:
Code:
Makefile:535: /usr/src/linux-2.6.33.4/arch/i486/Makefile: No such file or directory
make[2]: *** No rule to make target `/usr/src/linux-2.6.33.4/arch/i486/Makefile'. Stop.
make[1]: *** [modules] Error 2
make: *** [all] Error 2
looks like the folder i486 doesn't exist
I am running Valgrind on my program. It shows me two errors but mentions only addresses against them and not actual code even on a debug build.
The output is
==23002== Memcheck, a memory error detector.
==23002== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==23002== Using LibVEX rev 1575, a library for dynamic binary translation.
[code]....
None of my daemon scripts work now, and the startup process displayed errors. Should I reinstall the OS and start from scratch, or is there a way to recover these files? Is there a way to rebuild the files I deleted?
View 2 Replies View RelatedI have problems with linking object files.
This is what I get:
I want to define _LINUX in my makefile which I would be using in my source code like #if _Linux. I do not want to #define _Linux __linux__ in my source code.
View 2 Replies View Relatedat present I compile the same code for different systems (cross compilers)I need to call libs and include paths for the different processors. At present I simply comment out the paths not needed
eg
#INCDIR = -I/cross1/.......
#INCDIR = -I/cross2/.......
[code]....
could you please explain few questions about systemtap.
1st
===
seems gettimeofday_s() always returns 0 Code: stap -ve 'probe timer.s(4){ printf("%d ",
[code]....
I am a beginner in Linux. Never did any kernel programming in Linux/Windows before. I am now on a project and I am supposed to understand a Linux Device Driver Code. It contains 6 .c files and 1 Makefile.
The make file goes as this:
I have a.c b.c c.c d.c d.c e.c f.c in the director along with the Makefile mentioned.
I am using Fedora Red Hat Linux 32 bit.
How to compile the Makefile.
How to create a simple Makefile using C....
View 3 Replies View RelatedI'm trying to figure out how Make handles directories.
How can I modify this makefile so it will put all of the .o files in a separate build directory?
Code:
But make ignores this and still puts main.o in the base directory. And if I refer to the build directory in the dependencies for bandit, make complains about "no rule ..."
I want to keep main.cpp in the base directory, all other sources in the src directory, and all object files in the build directory.
When I put a "test" target in my Makefile containing
Code:
@echo "CXX= $(CXX)"
it tells me "CXX= g++".
But I have nothing in the Makefile assigning any value to CXX, and as far as I can tell I have no CXX environment variable (no "CXX" appears when I run the shell command "env", and "echo $CXX" returns a blank line. So where's the g++ value coming from. Is this just built into Gnu Make, or is there a configuration file for make somewhere?
Where are the definitions for C library functions located? It was just recently that I realized that header files don't actually define any functions, they merely include their prototypes.
For instance, stdio.h includes the following line:
Code:
This just means that the definition of printf() is located in another file. What file? Is there some kind of default shared object file that is automatically included during compilation?
I have problem to use an alias that defined in ksh93 script,in the functions in the same script onm Linux.I definied an alias in main: alias echo='echo -e' in order that echo will read backslashes but when i executed it in function, the alias didnt work, and performewd a regular echo, without -e
cat test.ksh
#!/bin/ksh
alias echo='echo -e'
checkUsage
[code]....
have an application where from time to time I need to check the db for some value and run some functions to do some checks. is the best option do it as php daemon or cron job?Whatworried of cron job is the overalapping.
View 9 Replies View RelatedBut what is the difference between this...
Code:
my_fucnction () {
echo "Hello World"
}
Code:
function my_fucnction {
[Code]...
Im implementing a chat application using Jabber/XMPP and gloox framework which should send and receive messages concurrently in Ubuntu Linux.
The problem faced is both the threads are created and pthread_join( ) is called for both.The iSend thread is scheduled first but gets suspended at cin. Once the recv( ) function is called, which runs in iRecv thread, the recv call back function handleMessage( ) is called. However the control never shifts back to the iSend thread which should call SendMessage( ) function.
I am trying to write a simple program in C that involves nesting switches. For example switch 1 offers an option to go to module 1 or 2 or quit. when I go to module 1 there is another switch function offering two or more choices.
I can select either module 1 or 2 at the start of the program and the selection text for, say, module 1 prints to screen but then exits without allowing a second selection to be entered.
I tried using free([first selection]) thinking that might do the trick but it doesn't.
Is it possible to next switches on after another in C?
The pthreads library on macos does not have barrier functions (pthread_barrier_t ....). Is there a way to get around this? I know I can do :
#ifdef __APPLE__
pthread_barrier_t ...
#else
my_barrier ...
#endif
But I would like to avoid this approach as there are a lot of places in my program where I would have to make this change. Can I perhaps rebuild the pthreads library on macos without affecting other apps ?
I am trying to run a script to setup environment variables and then run other commands in a make file. But the source or the dot operator (shell is bash) does not seem to take any effect as the subsequent command didn't pick the environment up. Do I have to put every lines of the environment setup in the first script into the makefile instead?
sample setenv.sh
#!/bin/sh
export MYDIR=/somedir
sample makefile:
all: source ./setenv.sh
echo $(MYDIR)
I'm learning about how to write Makefiles, and am a bit lost at how to run a command in a target depending on the value of a variable.
What I'm trying to do, is run "strip" only if the user is running a given version of a C compiler.
Here's the code:
Code:
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
#FDPIC ELF binaries can be stripped, but not FLAT binaries
$(if($(CROSS),bfin-linux-uclibc-),
$(STRIP) $@
;)
Does someone know the correct way to do this?