Changing name of application file (.C file) - c++

I changed the name of an modified application to seperate it from the basic application. Lets say the .C file of the old application is "OldApplication.C" and of the new modified one is "NewApplication.C" Unfortunately, when trying to start the new modified application in terminal by typing "NewApplication" I get:
NewApplication: command not found
Two Question:
How can I make my new application executeable?
Can someone give me a brief overview about the files of a project/application and their functions?
greetings, streight

The mistake of this kind
make: * No rule to make target OldApplication.dep', needed byMake/linuxGccDPOpt/dependencies'. Stop.
often occurs in situation when the Makefile ceases to comply with the structure of the whole project.
In your case make script obviously trying to find the file that was renamed by you and therefore it fails with en error. I think that you should explore the structure of your Makefile and replace all the changed file names with its new versions.
Also you say the you are refused to launch your new executable, but what else could be expected since the project was not compiled?

Related

Xcode writing to file issue

I'm trying to help my son with a Programming C++ for Engineers course. I got him set up with Xcode 13.1 on his iMac but I've never used it myself. That was working great until his first assignment that required writing output to a file. We created a new Command Line Tool project and then used the File->New->File... option to create an Empty file. After doing so, selecting that file and looking at the info on the right side of the window shows that the Full Path is pointing to the directory where his main.cpp file is. Yet, when running his code nothing was being written to the file. I had assumed that just referencing the file name in his code would cause it to use a local reference and look in the same directory as main.cpp. After much Googling I found a reference that said to go to Product->Scheme->Edit Scheme... then select the Options tab in the window that opens and change the Working Directory from "$(BUILT_PRODUCTS_DIR)" to the directory containing the main.cpp file. That got the programming working correctly. My questions are:
Is there a preference setting that would tell it to always use the current project directory so that we don't have to change this every time?
Where does "$(BUILT_PRODUCTS_DIR)" point to?
What should we be doing differently?

how do I create files on sciTE for c++?

I am newly learning c++. I am using the Linux ubuntu operating system and a sciTE text editor.
Do you know how to create a file on scite that I will be able to compile and then create an archive on terminal? also how do I create a 'make file. cpp'. Any help will be greatly appreciated.
Thanks! :)
Do you know how to create a file on scite that I will be able to compile and then create an archive on terminal?
You can use any text editor to write C++ source code. There is nothing very editor-specific about it. The file itself should be assigned a name that your compiler will recognize as designating a C++ source file. Compilers generally look at the filename extension for that purpose, and ".cpp" is a very common pattern recognized as indicating C++ source. It looks like that's what you're intended to use, so when you save the file just be sure to give it a name that ends in .cpp.
In order to successfully compile, you of course need to write valid C++ source code in the file, and in order to compile it to a program (I assume that's what you meant by "archive") it must contain a valid main() function.
how do I create a 'make file. cpp'.
I think you've gotten your instructions confused. Perhaps the instruction is just meant to convey what I already said about giving your source file a name ending in ".cpp". Alternatively, you may have been asked to create a makefile, which is input to the build tool "make", that could be used to build the program instead of running the compiler directly. You may ask specific questions about make here, but we are not in the business of writing full tutorials. The first thing you should do if you need instructions about make would be to consult your course materials and lecture notes, and / or ask your instructor.
On the third hand, make doesn't even need a makefile in some simple cases. It may be that you are instructed to build the program without a makefile. If you have named the source "prog.cpp" and it contains valid C++ source for a complete program, then you should be able to build that program via the command "make prog". In that case, the resulting program will be named "prog".

(C++) How can I test the new application in MOOS-ivp?

I've got a problem with compiling my basic code with MOOS-ivp.
I made main.cpp, simpleApp.cpp and simpleApp.h from documentation, where should I put it to build it with moos? In docs there is note about launching MOOSDB and uMS - ok, but there is not any option to find path to my .cpp file. Is there any default path? Maybe should I compile it firstly with gcc?
I'll assume you know some basic information about MOOS or are taking the MIT 2.680 course and know some of the terminology talked about in the introduction lab.
The recommended way to build external MOOS is to have moos-ivp and moos-ivp-extend in a directory next to each other. You should run GenMOOSApp_AppCasting in the moos-ivp-extend/src directory and add your new project to the CMakeLists.txt file in the same directory. Then, use the included ./build.sh script to build your executables, and add the directory it makes to your $PATH.
Finally, you should be able to run your mission with your new MOOS app.

Modifying the contents of a .cpp file

UPDATE: I am now able to compile the .cpp file with make
(I can see the compilation output). However, the changes does not seem to take affect.
After i run make, i restart the computer, but still no changes.
As you probably understand, I have very limited experience with c++.
I am currently working on a project (OpenBTS) and have found an error in one of the .cpp files after the project has been built and installed.
My question is, how can I modify the contents (f.eks change the string of a JSON data reference) of a .cpp file and build it so I can see the changes afterwards?
I have currently tried the following:
1.
make 'filename.cpp'
make: Nothing to be done for 'filename.cpp'
2.
make 'filename'
g++ 'filename.cpp' -o 'filename'
In file included from 'filename.cpp:29:0:
'filname.h':26:21: fatal error: Timeval.h: No such file or directory
#include <Timeval.h>
compilation terminated.
3. Run make from root directory:
Nothing to be done for 'all.'
4. Run make clean and make from root. This rebuilds the project but the
changes are still not in effect (I can see that the JSON String is not
changed at the webserver).
5. Run ./build.sh script. Still no changes.
Regarding the 2. method, as the project was built and compiled successfully, how come when i try that with a single file, the compiler can't find the header files? The only thing i changed was a string from "ARFCN" to "ARFCNtest".
Since there are about 50 header files that depends on each other, changing the include from <> to "" and copy every single file into the same directory seems like a waste and unnecessary action?
The changes didn't take effect because the compilation failed. See the error message you quoted in the question. Fix that and rebuild.
Incidentally, restarting your computer shouldn't be necessary. Even the make clean shouldn't be necessary if the Makefile correctly expresses the dependencies. (It seems to do so in this case since it tried to recompile the source file you modified.)

How to create a makefile without having to include every single source file in the project?

I'm taking some C++ classes and have send the teacher 9 exercises, each exercise is a simple directory with the name 'ex$' where $ is the number. Each directory has a single source file named 'ex$.cpp. I want to create a makefile that will allow me to type:
make ex$
And it will build a executable that corresponds to the compiled source file inside 'ex$' directory. The catch is that I want to do that without creating a target for each exercise(Some kind of 'generic target'). I also need to have an 'all' target that will go into each directory starting with 'ex' and build the executable there. How can I do that?
If all your C++ targets can be built with essentially the same command, you can do this fairly easily. Read this. Look for $#, in particular. Since this is part of an education, I'll leave the rest vague.
Can I also suggest looking at CMake which will make better makefiles for you to use IMO. Initial high learning curve for major long term gain. :)