adding release build to project Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
ValeV

adding release build to project

Post by ValeV »

Hi,

I made wxWidgets application (CodeBlocks, with wxSmith). At the creation, I checked I only want Debug build. Now I am building wxWidgets for Release build as well, and am wondering what's the easiest way to make same application with both Debug and Release builds.

Can I make new project with same name and copy pasty all files from existing project?
ValeV

Re: adding release build to project

Post by ValeV »

I got it. You have to copy paste wxsmith folder, [strike]cbp file[/strike] Main.cpp, Main.h, App.cpp, App.h, and all other .cpp and .h files you maybe created.
Last edited by ValeV on Thu Mar 21, 2019 12:02 pm, edited 1 time in total.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: adding release build to project

Post by doublemax »

ValeV wrote: Wed Mar 20, 2019 3:23 pm I got it. You have to copy paste wxsmith folder, cbp file and all other .cpp and .h files you maybe created.
I don't use wxSmith or CodeBlocks, but that doesn't sound right. You certainly don't have to copy any source files for that. Usually CodeBlocks should create both the debug and release configurations when you create the project. At most you have to set some paths.

But i can't tell you exact what you need to do.
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: adding release build to project

Post by PB »

Firstly, you need to have wxWidgets built in the release mode too, which I assume you have. If not, build them (adding "BUILD=release" to the command line). I also assume your Debug build target is fully functional and you can build and run the application as expected.


I am not really using Code::Blocks, but here is how I would add copy a debug to release build target io an existing project in Code::Blocks (v17.12):
  1. In the "Management" window at the left side of the IDE, go to tab "Projects", right click on the project name in the "Workspace" tree and from the menu choose "Properties...".
  2. In the dialog "Project/target options" go to the tab "Build targets" and you should see your only target "Debug" there. Highlight the target, click "Duplicate" button, set the name for the new target to "Release" and click "OK" button.
  3. Now highlight the "Release" target in the "Build targets" list on the left side and click "Build options..." button.
  4. In the displayed "Project build options" highlight the "Release" target, go to "Linker settings" tab and in "Link libraries" change the names of all wxWidgets libraries from debug to release versions, i.e., basically delete the "d" somewhere at the end of the library name, e.g.,"libwxmsw31ud_richtext.a" or "libwxexpatd.a".
  5. Similarly, remove the "d" from "mswud" in the paths in "Search directories" tab for "Compiler" and "Resource Compiler".
  6. If necessary, adjust the defines in the "Compiler Settings" tab in "#defines", e.g., remove "__WXDEBUG__" and add "NDEBUG"
If you use wxWidgets built as DLLs (SHARED=1), you also need to make sure the release versions of wxWidgets DLLs are available to your application.
ValeV

Re: adding release build to project

Post by ValeV »

PB wrote: Wed Mar 20, 2019 7:27 pm Firstly, you need to have wxWidgets built in the release mode too, which I assume you have. If not, build them (adding "BUILD=release" to the command line). I also assume your Debug build target is fully functional and you can build and run the application as expected.


I am not really using Code::Blocks, but here is how I would add copy a debug to release build target io an existing project in Code::Blocks (v17.12):
  1. In the "Management" window at the left side of the IDE, go to tab "Projects", right click on the project name in the "Workspace" tree and from the menu choose "Properties...".
  2. In the dialog "Project/target options" go to the tab "Build targets" and you should see your only target "Debug" there. Highlight the target, click "Duplicate" button, set the name for the new target to "Release" and click "OK" button.
  3. Now highlight the "Release" target in the "Build targets" list on the left side and click "Build options..." button.
  4. In the displayed "Project build options" highlight the "Release" target, go to "Linker settings" tab and in "Link libraries" change the names of all wxWidgets libraries from debug to release versions, i.e., basically delete the "d" somewhere at the end of the library name, e.g.,"libwxmsw31ud_richtext.a" or "libwxexpatd.a".
  5. Similarly, remove the "d" from "mswud" in the paths in "Search directories" tab for "Compiler" and "Resource Compiler".
  6. If necessary, adjust the defines in the "Compiler Settings" tab in "#defines", e.g., remove "__WXDEBUG__" and add "NDEBUG"
If you use wxWidgets built as DLLs (SHARED=1), you also need to make sure the release versions of wxWidgets DLLs are available to your application.
Thanks, I did it, but when I run the Release build, it throws some strange errors (like when I close the application get segmentation fault on "IMPLEMENT_APP(DataGetterApp);" in DataGetterApp.cpp). Also it didn't make an .exe file in "Release" folder. But it's an interesting solution which helped me understand stuff a tad more.

doublemax wrote: Wed Mar 20, 2019 5:34 pm
ValeV wrote: Wed Mar 20, 2019 3:23 pm I got it. You have to copy paste wxsmith folder, cbp file and all other .cpp and .h files you maybe created.
I don't use wxSmith or CodeBlocks, but that doesn't sound right. You certainly don't have to copy any source files for that. Usually CodeBlocks should create both the debug and release configurations when you create the project. At most you have to set some paths.

But i can't tell you exact what you need to do.
When I created original project, I didnt build wxWidgets with BUILD=release yet (only with debug), so I couldn't choose to also make Release version (CB doesn't create both configurations on its own, you have to tell him which ones you want), when I created the project.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: adding release build to project

Post by PB »

Sorry, I forgot to mention that you also need to change the paths for the Release target. Mixing builds in the same folder can lead to bad things happening.

In "Build targets" tab of "Project/targets options" dialog select the "Release" build target and replace "Debug" with "Release" in "Output filename" and "Objects output dir".

Make sure to clean both targets, probably best would be manually deleting everything in the "bin" and "obj" folders of your project.

I tested creating the Release target from the Debug one using the procedure described (with a wxWidgets project created with C::B project wizard) and it worked.

If you still encounter issues, doublecheck that all required settings were properly changed in the Release target, in particular focusing on the library names...

But, there are also bugs that manifest only in the Release builds but hopefully yours are not one of those.
ValeV

Re: adding release build to project

Post by ValeV »

I can try it, but is it really necessary? I already made new project and copy pasted necessary files from original project. Is the way you described more formal, less error prone? Should I use yours nontheless?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: adding release build to project

Post by PB »

Yes, having multiple build targets in a single project is the standard way.

TBH, I do not understand how you want to do it, as one does:
1. need both debug and release targets
2. not want to maintain two projects for one application..
ValeV

Re: adding release build to project

Post by ValeV »

I see, so to make it clear

-I first built wxWidgets just with BUILD=debug. So I didn't have release configuration available.
-I made application (naturally only with debug configuration)
-I realized I need release conf as well.
-Built wxWidgets with BUILD=release
-Made new Project, copy pasted the files from previous one.

My alternative to last line is to follow the guide you posted, but I want to know if it's necessary, or will I get the same result.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: adding release build to project

Post by PB »

I am sorry I do not have anything new to add to what I already said.
ValeV

Re: adding release build to project

Post by ValeV »

I understand, and I sincere thank you for posting those instructions. I will save them for the future projects. :)
Post Reply