Configure the compiler output path in Netbeans

Asked

Viewed 1,314 times

5

Would anyone know how to configure in Netbeans, so that when I compile a project, it manages the executable in a given folder? In the project properties, you have the binding option, which I believe is the output of the program, there this directory:

${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/meu_prog

Does anyone know what these macros mean? How to change this directory?

  • When we generate the .jarapplication it already goes to the project folder that does not suit you?

  • No. Here the project is in C. The file it generates is a . exe (Windows), but in the context, the same as the . jar which is the executable of a Java project. But what I intend to do, is that . exe or . jar go to a directory defined, for example, I want that after the compilation of the project that is in Folder C: Netbeans Projectotest, the executable stops on my Desktop, ie the . exe or . jar.

  • It would be appropriate to change the title to something like "Setting up the compiler output path in Netbeans" (as an example). The way it is, it looks like you want to set up the location of gcc, javac or another compiler you’re using.

2 answers

2


Yes, it is in this location that changes the file destination, only the directory separator is / and not \.

If there is a directory with the same name as the output file, you may need other settings like putting the . exe at the end of the name in the run configuration (Propriedades -> Executar -> Comando Executar).

Documentation of what it means is in the archive Makefile, or at least clues for those that are not exactly the same as those listed. In the project, it is in a folder called "Arquivos Importantes" or "Important Files" in the English version.

  • CND_DISTDIR: distribution directory, where the final files will be;
  • CND_CONF: It doesn’t say, but it’s the configuration used, it seems equivalent to ${CONF}: Has value Debug, Release or another name you create in the project properties;
  • CND_PLATFORM: the target platform, from what I saw is the name of the compiler (defined by you) and the host operating system that is building the program. It can be Cygwin_4.x-Windows, or Arduino-Windows, Arduino-Linux, AVR-Linux, etc..

You can also, without changing the program’s destination, copy it to the location you want by adding the command in the section .build-post of Makefile. If you want to run/debug in the new location change the settings of the Run and Debug commands. Example: after lines

.build-post: .build-impl
# Add your post 'build' code here...

In Windows, add the line:

${CP} ${CND_ARTIFACT_PATH_${CONF}}.exe ${USERPROFILE}/Desktop/

On Linux, the line is:

${CP} ${CND_ARTIFACT_PATH_${CONF}} ${HOME}/Desktop/

Important: This line starts with a character [Tab], otherwise does not work.

Important 2: Not always the ${USERPROFILE}/Desktop/ works. For example: In Windows I changed my desktop folder, and this path does not copy the file to my desktop. (Because I changed is another story) On Linux the environment I don’t even use the Desktop folder.

  • I received this error by adding the line you passed: nbproject/Makefile-variables.Mk:13: *** Recursive variable `Cnd_artifact_path_debug' references itself (eventually). Stop. gmake: ** [.clean-impl] Error 2

  • @Vynstus Wow, here I created a project appteste, with Makefile, main file in C, tools Cygwin_4.x. I went into the Makefile, glued the line without moving, put the character TAB (It was difficult, NB insists on transforming into spaces) and I had it run. Compiled and executed without errors (because it has no code, only returns). Ah, the file went to the right folder, which is not my desktop. What versions do you use? My Netbeans IDE is 8.0.2, C/C++ support 1.27.2.1, Cygwin 4.x with GCC 4.9.2. - In the Makefile your NB generates, you have the variable description CND_ARTIFACT_PATH_${CONF} at first?

  • It is the same version, with C/C++ support. My gcc is from Linux, the netbeans project is using the build host of a Linux server, and the project is compiled there. Directory where it saves the executable is : /home/user/. netbeans/remote/192.168.1.x/pc-Windows-x86/C/Users/fulano/Documents/Netbeansprojects/Project_test/dist/Debug/GNU-Linux-x86

  • I did it on Linux: I created appteste, all the same, only the line is a little different, I will update the answer. Anyway, the output you quoted is another problem. Check if the file {diretorio do projeto}/nbproject/Makefile-variables.mk is being raised properly. If I use one of my NTFS drives I have problems because I mount in a way that prevents execution, check this too, try creating a local project to test. In this file, cited in its first comment, the corresponding line, on Linux, is: CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux-x86/appteste.

  • @Vynstus Ah, another difference, not that it changes anything, but in my Linux the version of GCC is gcc (Gentoo 4.8.4 P1.6, pie-0.6.1) 4.8.4

  • @Vynstus Ah, another thing: If the build host is a Linux server, it may be that the Makefile is interpreted on Linux and cannot copy the file directly to your desktop, I don’t know exactly how it is done and I can’t test it. Assuming this is true and everything else works, maybe you can mount the disk on Linux and copy to the right location.

  • Actually I didn’t want to copy to the Windows desktop but in the home linux folder. , my gcc is this: (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)

  • Well, I never used remote host for build in Netbeans anyway. The closest I got to this was distributed compilation, without Netbenas, but then the central host controls everything and receives the results, not the others. Build on remote host is an extra complication and I can’t test such an environment right now.

Show 3 more comments

0

@Rafael

I was needing the same thing, so I found an answer in the English community that served me.

Basically you can change the directory of the folder dist who finds his .jar (or .exe) changing the value of the property dist.dir in the archive project.properties (in the case of a java project) of your project located in the folder nbproject

dist.dir = dist

To:

dist.dir = /../Desktop 

In my case I put the way of my work area. Put the whole way there of your.

Reply link in English: Link

  • In my nbproject folder you do not have the project.properties file, no file with this extension. Only files with extension . bash, . xml and .mk. My project is a C application I don’t know if it differentiates the files...

  • So I created a project c here to test and apparently the equivalent in the project C is the laucher.properties inside the briefcase private of nbproject. Test in this file.

  • I did, but he doesn’t have the dist.dir = dist line

  • Yes, but I think there is a macro there related to the dist path that says you can use it. Try to change it. And if you add this line dist.dir= it from the error?

  • I couldn’t find them, they are all marked as a comment, that is, with the prefix #. I tried to add the line dist.dir= /.. /Desktop and compiled, but the file was not for desktop...

  • I’ll try here and give you an answer.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.