C :: Create Makefile For A Single File
May 20, 2013I'm trying to create a Makefile for a single fie ( mycod.c)
What is the syntax?
I'm trying to create a Makefile for a single fie ( mycod.c)
What is the syntax?
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"
I have an MFC application(.exe) in which i am creating an pointer object to CComQIptr<chemst::IChems>myinfo and after this i have using cocreate instance i had created the object launching that object, so Where i am using that CComQIptr object.
I have been creating instance to that COM exe (child exe) and at the end of the function i am releasing that object (myinfo->release).i want to create single instance for it and i want to use them in different .cpp files and finally i want to kill the child exe. Even though i release the object it is still alive.(Visualising in Task manager whether the exe is still alive or not).
Write a program that reads four integers from a file ‘input.txt’.
The program will then create a single integer number from the four integers. The output of the program will be the single number and single number + 600.
#include <iostream>
using namespace std;
int main () {
int number , a;
cout<<"enter en integer number";
cin>>number;
cout<<"add 600 to the number"
cin>>a=number+600;
return 0;
}
I created a simple program that writes some text to two different text files. how to create a program that would retrieve the information from those two files, and put them in a single file, first the content of input1 and then the content of input2. how to do this. Here is the program that I created that creates the two files.
#include <iostream>
#include <fstream>
#include <string>
int main() {
using namespace std;
string input1;
ofstream fout("input1.txt");
[Code]...
When I try to compile a single file with GCC (I'm using Code::Blocks as my IDE if that is relevant) it gives me a bunch of undefined reference errors. Well, of course they are undefined since I haven't linked anything yet, but why is GCC complaining at compiling time?
The problem is that when I try to link and compile the project in one go I don't get any errors. The references in question are from the GLEW library if that is relevant.
srccharrenderer.o:charrenderer.cpp|| undefined reference to `_imp____glewDeleteBuffers'|
srccharrenderer.o:charrenderer.cpp|| undefined reference to `_imp____glewDeleteBuffers'|
srccharrenderer.o:charrenderer.cpp|| undefined reference to `glEnableClientState@4'|
srccharrenderer.o:charrenderer.cpp|| undefined reference to `_imp____glewBindBuffer'|
srccharrenderer.o:charrenderer.cpp|| undefined reference to `glVertexPointer@16'|
[Code] ....
Here are all the errors I get.
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]
How would i get the total amount of elements From the input file(The .dat file) and then store them in a variable?Here is an example to show you what i want. If a line on the .dat file looked like this
1 2 3 4 5 6 7
How would i find the total number of elements? For example the total number of elements in this line would be 7.
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] .....
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
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
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
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)
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] .....
I am trying to read in player names (ex: first last) from a text file into the people[].name data struct. I can successfully read in my card file, but I cannot get this to work. I get a seg fault. I believe this is because nothing is actually being read in for my while loops. I can't use std::strings so these must be c-style strings aka char arrays.
// deck of cards
// below are initializations
#include <iostream>
#include <fstream>
#include <ctime>
#include <stdlib.h>
#include <string>
using namespace std;
//globals
const int maxCards = 52;
[Code] .....
I need to create a project that create a automated backup of a file.
i will get the file from C:/Folder/file.exe and move for a other created folder, but.. in every time that user make this backup, a folder will be created with year, month and date, like: C/Folder2/2014/April/16:42/file.exe.
The Objective Of This Program Is To Create A File To Write Text And Read Back The File Content. To Do That I Have Made Two Function writeFile() To Write And readFile() To Read.The readFile() function works just fine but writeFile() doesn't.
How writeFile() function Works? when writeFile() function Execute It Takes Characters User Type And When Hit Enter(ASC|| 10) It Ask "More?(Y/N)" That Means What User Want? Want To Go Next Line Or End Input?
If "Y" Than Inputs Are Taken From Next Line Else Input Ends.
But The Problem Is When Program Encounters ch==10 It Shows "More?(Y/N)" And Takes Input In cmd variable.If cmd=='Y' I Mean More From Next Line Than It Should Execute Scanf Again To Take ch I Mean User Input.But Its Not!!! Its Always Showing "More?(Y/N)" Again And Again Like A Loop.
Code:
#include <stdio.h>
void writeFile(void);
void readFile(void);
int main(){
[Code].....
I am interested in creating a file of a given size and then randomly accessing the file to populate it. Is there a way to quickly create, for instance, a 4 GByte file in C++, initially populated with garbage?
View 4 Replies View RelatedI have a folder "pics" in g: drive. There I want to create some text.txt file. Thus, the final path is "g:pics ext.txt".
How can I do that?
How do you create a save file for a game, that is not a separate file? Specifically I am using code::blocks and sfml 2.1 to make a game and it saves to a text file at the moment. My problem is that it is very easy to modify the text file, and it is annoying to have to copy and paste several files if you want to use a copy of the game. I have a feeling that it may be to do with resource files, but I'm not exactly sure how to get these to work or whether you can modify them dynamically.
View 6 Replies View RelatedI think this code should create a test.txt file but I cannot find it ?
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream ofs;
ofs.open ("test.txt");
ofs.close();
return 0;
}
I want to create a program that would take an AVI file, alter each frame (ex: change contrast, invert colors, etc.) and dump a new AVI. I've wrote a simple program for this experiment that loads up the header information from the video and dumps it. It also dumps a list of the frame data chunks within the 'movi' chunk.
The info I've gathered from coding this:
1. The recommended buffer size for each type of stream (vids, auds, etc.) is the size of the largest frame of corresponding type, plus 1 or two extra bytes.
2. numFrames in main header is the total number of frames for all types of data (video,audio,etc.) The 'length' value within stream header of type 'vids' is the number of video frames. The sizeImage value within BITMAPINFOHEADER is 921600 (==640*480*3) and the specification states that, quoth, "This can be set to 0 for uncompressed RGB bitmaps."
3. This video uses DIVX encoding.
Now my problem is this: How do I get the data within each video frame in a simple BMP like format? Even the uncompressed frames (with chunk id 'nndb') have variable sizes...let alone the compressed ones.
Information about a software that converts AVIs to a format with fixed sized uncompressed frames. Or at least some information about the frame decompression techniques.
Here's a dump made by the program for a 9 sec, 640x480 video I recorded from Pokemon. (Without the frame dump that is, it'd have made the post too long.)
Code:
AviMainHeader
-------------
size = 56
usecPerFrame = 66666
maxBytesPerSec = 7680000
padSize = 0
flags = 0x00000810
numFrames = 162
initialFrames = 0
numStreams = 2
[Code]...
How do i create a data file?
View 2 Replies View RelatedI now have a file with X, Y, Z and Intensity (0-1) of all the pixels. I want to create a .bmp file (grayscale) with this information in C++. How to do it?
View 1 Replies View RelatedAny good/solid example on how to create a header file?
View 2 Replies View RelatedIm having problems with this little function im making
for some reason the texture dont get created (messagebox never gets called)
Im trying to pass a BYTE array of a image to the function
void AddTexture(BYTE* texture)
{
LPDIRECT3DTEXTURE9 Direct3DTexture = NULL;
if (D3D_OK == D3DXCreateTextureFromFileInMemory(pDevice, &texture, sizeof(texture), &Direct3DTexture))
{
MessageBoxA(NULL, "created", "created", MB_OK);
}
}