C++ :: What Is Dependency In Makefile

Aug 7, 2014

What is dependency in Makefile.

Secondly I have made Makefile but cannot use make -f . How to use it?

Third what is make [OPTION] [TARGET]

View 4 Replies


ADVERTISEMENT

C/C++ :: How To Remove Circular Dependency

Jan 23, 2014

I have ran into some sort of Circular dependency between two classes.

Forward declaration doesn't work as I'm allocating the memory for pointer array of Student and it requires the default constructor.

P.S I'm aware I haven't written the BIG 3, it's an incomplete code. Just want to know how to resolve this dependency.

class Student;
class Course {
char *name;
Student *s[3];

[Code].....

View 14 Replies View Related

C++ :: Class Definitions Have Interwoven Dependency

Mar 29, 2013

I have an exercise from my text that defines a StrBlob class, then a StrBlobPtr class to hold weak pointers to the StrBlobs. This is from C++ Primer (5th Edition) and coincidentally, the entire chapter is available on-line at here.

My problem is that the begin and end functions of StrBlob can't be defined until the entire StrBlobPtr class is defined. Forward declarations don't cut it, since begin and end need more than pointers.

The solution (if you also look at the errata for the book) seems to be to define StrBlob, leave begin and end undefined, then full define StrBlobPtr, and following that, finally define StrBlob::begin() and StrBlob::end().

Anyhow, the above works, as I show in the included code below - but it seems like a hack and messy. What would be the proper way to do this? My text may be obfuscating the issue in the pursuit of pedagogy.

Additionally, how would one separate StrBlob and StrBlobPtr into there own headers? I'd think it impossible, since the StrBlob would have to nestle an "#include "StrBlobPtr.hpp" in the center of it's own definition...?

Code:
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <stdexcept>
class StrBlobPtr; // Forward declaration

[Code]....

As I said, the above works (compiles, haven't -tested- it extensively) but it seems messy.

View 2 Replies View Related

C++ :: Circular Dependency In Template Arguments

Nov 7, 2013

Today I faced a problem where I had circular dependency in my template arguments. I was trying to make a class hierarchy similar to:

template<class BType>
class A_base {
public:
BType* getB();
};

[Code] .....

Basically I had objects that were of type A<B<A<B<...

Basically I have a tree like structure of heterogeneous types that must facilitate two-way interactions where A's can call B's and B's can call A's. This structure is useful in many contexts the difference is the methods A and B provide are different in each of these contexts. Instead of adding the getA and getB and all the other connectivity methods in every version of A and every version of B, I wanted to create a base class that managed this automatically.

Another piece of advice was break up your code so there is a forward-only and backwards-only dependent types. This is not a complete solution because the two cannot know about the other and this does not really facilitate arbitrary two-way communication (where A calls B then B calls A back). It also makes the code more complicated in that I have two sets of objects and interfaces.

So the solution was to make the template arguments specific to the things I wanted to be flexible. The connectivity interface of A_base and B_base should be constant. Hence that cannot be in the template parameter. It was merely the traits that I wanted to make flexible so... I came up with this solution:

#include <iostream>
template<class aTraitType,class bTraitType>
class A;
template<class aTraitType,class bTraitType>
class B;

[Code] ....

Now this compiles and works great. The problem is that aObj and bObj cannot call their opposite within a trait method because print() does not know anything about the connectivity. So the solution there was to make traits an abstract base class. Then magically everything works!

#include <iostream>
template<class aTraitType,class bTraitType>
class A_base;
template<class aTraitType,class bTraitType>
class B_base;

[Code] .....

So this outputs the following. Clearly there is two-way communication!

Class A is not connected to B
Class B is not connected to A
Class A at 0x7fff25d1aa10 reporting for duty
Class B at 0x7fff25d1aa00 reporting for duty
Class B at 0x7fff25d1aa00 reporting for duty
Class A at 0x7fff25d1aa10 reporting for duty
Class A at 0x7fff25d1aa10 reporting for duty
Class B at 0x7fff25d1aa00 reporting for duty

View 6 Replies View Related

C# :: Breaking Dependency In Static Method For Unit Test?

Feb 6, 2014

I have function that returns historical data. I can access it, using file name. If I use file name, it reads that file and saves it to dictionary, so that in the future, if historical data is required for the same file, it does not read it again (it's lazy loading). If no file is supplied to the function, it tries to read file which is given in app settings.

However, for unit testing, I do not want to read any file. Instead, I want it to use small sample of hardcoded historical data. In order to do that, I think, I need to introduce interface to it. Then I can use some IoC to choose between different implementation for unit testing purpose and ordinary launch of application.

Function to get history is given as follows:

public static class Auxiliary
{
private static Dictionary<string, MyData> _myData;
public static MyData GetData(string fileName = null)
{
// ...
}
}

I have created default Unit Test project with Visual Studio so, as far as I know, by default it uses MSTest as test runner and MSUnit as unit testing framework but it does not have any IoC container so I should manage NuGet packages for solution and install Unity.

As far as I know, MSUnit (aka Moles) can unit test static methods (it's unconstrained isolation framework, like Typemock Isolator, unlike NUnit) but still many people suggest not to use any static methods for unit testing.

Should I use shim or stub [URL] Stubs should be used for faking external dependencies and here it is not external library, but my own code.

View 1 Replies View Related

C++ :: Application That Has One Static Library Dependency - Linking Error

Feb 16, 2012

I am trying to build an application that has one static library dependency, however I am getting this error when linking:

1>ClCompile:
1> All outputs are up-to-date.
1>LINK : fatal error LNK1104: cannot open file 'TestWrapperLib.obj'

Why I might be getting that? I have the .lib in the depends line, and the directory where it is at in the include line.

View 1 Replies View Related

C++ :: Doubly Linked List - Circular Dependency Error

May 15, 2013

When compiling the source I get the following error

"pms_program.h:54:56: error: expected declaration specifiers or ‘...’ before ‘CourseType’"

the code you are looking for in pms_course.h ( there is a circular dependency between pms.h , pms_course.h and pms_program.h)

function prototype AppendProgram ( part of doubly linked list )

I have attached the full course code.

As much as I like I cannot change the structure of the startup code ...

please see attached zip file for the entire source code.

View 6 Replies View Related

C :: Compiling Makefile - Error

Feb 5, 2013

I've a problem compiling my makefile. The additional files are enclosed.

the error I get:
$make ./main
gcc -ggdb main.c
/tmp/ccPIxwjP.o: In function `main':
/home/ilan/Embedded_linux/Lesson-2-Makefiles/lesson-2.1/main.c:6: undefined reference to `func1'
/home/ilan/Embedded_linux/Lesson-2-Makefiles/lesson-2.1/main.c:7: undefined reference to `func2'
collect2: error: ld returned 1 exit status
make: *** [main.o] Error 1
$

Code:
my make file:
main : main.o file1.o file2.o
gcc -ggdb main.o file1.o file2.o -o gdb-main
main.o : main.c file1.h file2.h

[Code] .....

View 4 Replies View Related

C++ :: How To Create Makefile With Bin Src And Inc Subdirectories

Aug 1, 2014

use makefiles, how to create a makefile with cpp files and the binary file in different directories.

These are my directories:

Project/
|
|-makefile
|
|__src/__.cpp files
|
|
|__bin/__ .exe
|
|
|__inc/__ .h files
|
|
|__obj/__ .o files

I have done this:

CC = g++

CFLAGS = -I.

SRCDIR = src
OBJDIR = obj
BINDIR = bin
INCDIR = inc

SOURCES := $(wildcard $(SRCDIR)/*.cpp)

[Code] .....

but console says "no rule to make target main.cpp, needed by project"

View 2 Replies View Related

C/C++ :: Multiple Executables In Makefile?

Jan 31, 2014

How do I compile a more than one executables? If I have two rules to compile an executables, after it compiles the first, it will stop.

a: a.h a.cpp
g++ a.h a.cpp
b: b.h b.cpp
g++ b.h b.cpp

View 9 Replies View Related

C++ :: Makefile Only Executing First Entry

Mar 15, 2013

Why this makefile only executes the first entry, compiling only the first program listed?

###########################################################
#
# Simple Makefile for Operating Systems Project 2
#
###########################################################
vowcon:
g++ -o vowcon vowcon.cpp -pthread
osproj2c:
g++ -o osproj2c osproj2c.cpp -pthread
osproj2b:
g++ -o osproj2b osproj2b.cpp -pthread
osproj2a:
gcc -o osproj2a osproj2a.c -pthread
clean:
rm osproj2a osproj2b osproj2c osproj2d vowcon

View 7 Replies View Related

C++ :: Checking For IDConfig In Makefile?

Mar 29, 2012

How do I check for ldconfig in a makefile? This makefile errors because it tries to run ldconfig, even though OS = Darwin

Code:
ifeq ($(SHARED),1)
install: banner install_headers $(lib_target)
@echo "Install shared library"
cp -f ./$(lib_target) $(inst_path)
cd $(inst_path) ;

[Code] ....

Errors

Code:
/bin/sh: -c: line 0: syntax error near unexpected token `Darwin,Darwin'
/bin/sh: -c: line 0: `ifneq (Darwin,Darwin)'
make: *** [install] Error 2
make: ldconfig: No such file or directory
make: *** [uninstall] Error 1

View 3 Replies View Related

C++ :: Calling A Script From Makefile

May 18, 2013

I would like to call a script from a makfile to glean some information about the OS. What I more or less need is the OS name and version (CentOS-5.9, OPENSUSE-12.2, Cygwin, etc). I think I can get the rest of what I need from uname. The OS name and version doesn't seem to reside in any consistent place over the various Linux flavors. I also need to get the version of the gnu c compiler, since I think that may also require a bit more involved scripting than I would like to try out of make.

The main question is weather I can call a script out of make and have it return a value for a variable.

Something like,

OS := $(shell ./script_name)

View 1 Replies View Related

C++ :: Makefile Options To Compile For 64 Bit

Mar 17, 2014

I have called a C function inside C++ code. The .so which gets created is a 32 bit while I am looking for 64 bit . What all options should be mentioned in the Make file to eventually compile and get shared object of ELF64 CLASS ?

Excerpts from Makefile
-----------------------------

CC = gcc
CXX = g++
CPPFLAGS = -I. -I$(S) -DHAVE_CONFIG_H
CFLAGS = -O2 -pipe
CXXFLAGS = -g -O2
LDFLAGS =
LIBS = -lsocket -lnsl

[Code] .....

View 1 Replies View Related

C :: Create Makefile For A Single File

May 20, 2013

I'm trying to create a Makefile for a single fie ( mycod.c)

What is the syntax?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved