Compile c++ Projects

To compile a c++ program using CodeBlocks IDE the following block of code sucessfully accomplishes the assigned task.

[codesyntax lang=”cpp”]

void cmdLFrame::OnmenCompSelected(wxCommandEvent& event)

    wxFileDialog OpenDialog(NULL, "Select CodeBlocks Project File Now!", "/home/archman/workspace/cb/cpp/", wxEmptyString,
                            wxFD_OPEN | wxFD_FILE_MUST_EXIST);

    if (OpenDialog.ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
        cmd = "/usr/bin/codeblocks " + OpenDialog.GetDirectory().ToStdString() + "/" + OpenDialog.GetFilename().ToStdString() + " & ";



The OpenDialog command above allows the technician to traverse and select the desired CodeBlocks project.  After the project is selected the CodeBlocks IDE is invoked and development can continue.

The command line is dynamically constructed to include the selected project file as input.

The command processer is invoked by issuing the “system” command.

The ” & ” at the end of line tells the command processor to invoke the command in the background while not waiting for program completion.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply

Your email address will not be published. Required fields are marked *