how do i compile a project with files/codes in a subversion..

suppose I have these files in a version control:

folder/implement.cpp
folder/head.hpp

I want to compile my main.cpp with these files

What I did is:

$ g++ main.cpp ../svn/folder/implement.cpp -I ../svn/folder/ -o main

It doesnt work...

Pls give me link that gives the complete codes on how to compile diff programs in c++.

tnx in advance...

Dani AI

Generated

Short summary and immediate checklist. The usual causes are (1) attempting to build from repository internals instead of a working copy, or (2) compiling without producing and linking all required object files. As noted, the exact compiler/linker error text is crucial — it tells whether the problem is a missing header, an include-path issue, an undefined symbol at link time, or a duplicate-definition error. As pointed out, use the repository to get a normal working copy first.

Recommended minimal workflow (compile each translation unit, then link):

g++ -c src/lib.cpp -I include -o build/lib.o
g++ -c src/app.cpp -I include -o build/app.o
g++ build/app.o build/lib.o -o bin/app

Common causes and fixes:

  • "file not found" for an include: adjust the include path or use correct relative path when including headers.
  • "undefined reference": make sure the .o that defines the symbol is included in the final link line.
  • "multiple definition": remove non-inline function or non-const variable definitions from headers; keep only declarations there and use include guards (#ifndef/#define/#endif) or #pragma once.
  • Do not #include .cpp files into other .cpp files. Compile .cpp files separately and link their objects.
  • If using libraries, pass library directories with -L and libraries with -l, and remember link order matters for static libs.

For anything more than two files, use a simple Makefile or a build system (CMake) to avoid manual mistakes. Subversion usage and the working-copy concept are documented at the Subversion site: Subversion. For compiler flags and linking behavior consult the GCC manuals: GCC online docs.

Recommended Answers

All 2 Replies

>>It doesnt work...
what does that mean? what are some of the errors?

how do i compile a project with files/codes in a subversion..

suppose I have these files in a version control:

folder/implement.cpp
folder/head.hpp

I want to compile my main.cpp with these files

What I did is:

$ g++ main.cpp ../svn/folder/implement.cpp -I ../svn/folder/ -o main

It doesnt work...

Pls give me link that gives the complete codes on how to compile diff programs in c++.

tnx in advance...

I have not used subversion, only cvs and visual source safe. But they do not store source files using the usual file extension. They append a ",v" part at the end.
At any case, developers do not link the files in the repository directly. First they checkout them to a working folder and do the stuff from there. So first see if the ../svn/folder/implement.cpp file exists. It is likely that it doesnt exist, and what exists is a file like ../svn/folder/implement.cpp,v . If the ../svn/folder/implement.cpp,v exists, check the files to a working folder and build using them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.