Author Topic: Building project on command line with dependencies  (Read 6450 times)

Offline rgleim

  • Single posting newcomer
  • *
  • Posts: 8
Building project on command line with dependencies
« on: September 14, 2023, 07:33:10 pm »
I posted this question on Stackoverflow also: https://stackoverflow.com/questions/77106256/dependencies-not-being-built-from-command-line-execution-with-codeblocks

This is all within a Windows environment.

I have a main project that depends on 2 libraries (e.g. lib.a). When I rebuild through the Code::Blocks IDE, it cleans both library projects and the main project as expected. It then builds all 3 projects, libraries first, as expected with no issues.

I try to do the same thing from the command line:

Code
"C:\Program Files (x86)\STW\CodeBlocks\codeblocks.exe" src\emb\bwk\vehicle_monitor\pjt\vehicle_monitor.cbp --target="Release" --rebuild

But it doesn't clean or build the library projects like it does in the IDE, and therefore produces errors:

Code
tricore-g++.exe: error: ..\..\..\..\ext\micro_cdr\result\libmicro_cdr.a: No such file or directory
tricore-g++.exe: error: ..\..\..\..\ext\micro_dds\result\libmicro_dds.a: No such file or directory
Process terminated with status 1 (1 minute(s), 6 second(s))
2 error(s), 39 warning(s) (1 minute(s), 6 second(s))

I tried all command line options and I don't see any log files being produced either. I see them if I launch the IDE, but not when I just keep it to the command line.

Code
C:\>"C:\Program Files (x86)\STW\CodeBlocks\codeblocks.exe" "Z:\workspace\autoyard\src\emb\bwk\vehicle_monitor\pjt\vehicle_monitor.cbp" --target="Release" --rebuild --log-to-file --debug-log-to-file /d --verbose

Is there something I'm missing on the command line?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Building project on command line with dependencies
« Reply #1 on: September 14, 2023, 08:18:29 pm »
Do you have external dependency files setup under

Project -> Properties
Tab: Build targets
Button: dependencies

I am guessing the answer is yes; but, it is best to make sure.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline rgleim

  • Single posting newcomer
  • *
  • Posts: 8
Re: Building project on command line with dependencies
« Reply #2 on: September 14, 2023, 10:08:56 pm »
Attached are screen shots of some of my settings

Offline rgleim

  • Single posting newcomer
  • *
  • Posts: 8
Re: Building project on command line with dependencies
« Reply #3 on: September 14, 2023, 10:09:36 pm »
more

Offline rgleim

  • Single posting newcomer
  • *
  • Posts: 8
Re: Building project on command line with dependencies
« Reply #4 on: September 14, 2023, 10:11:58 pm »
External Dependencies attached.  Not really sure how to use this.  It works as I expect when I build inside the IDE.  Why would it be different on the command line?

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Building project on command line with dependencies
« Reply #5 on: September 14, 2023, 10:35:57 pm »
Looks like relative paths for include & libraries. Then you must have same current dir in both cases.

Offline rgleim

  • Single posting newcomer
  • *
  • Posts: 8
Re: Building project on command line with dependencies
« Reply #6 on: September 14, 2023, 10:45:42 pm »
Correct. Everything is relative paths based on the current dir. I tried including external dependencies as well, but still no good.

Could someone setup a simple test project where there's a lib, built in code blocks, and a project that has a dependency on it. Then see it "clean" and "build" both projects in the IDE, when just calling on the main project, and then try to repeat on the command line?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Building project on command line with dependencies
« Reply #7 on: September 14, 2023, 11:06:51 pm »
External Dependencies attached.  Not really sure how to use this.  It works as I expect when I build inside the IDE.  Why would it be different on the command line?

If that is blank then you are using workspace depends; if you are using that then you should try building the workspace instead of the CB project.
Edit: I have no idea if that is possible.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline rgleim

  • Single posting newcomer
  • *
  • Posts: 8
Re: Building project on command line with dependencies
« Reply #8 on: September 14, 2023, 11:32:36 pm »
I found the attached on the code::blocks wiki, but after setting up the external dependencies in the project, it's still not working on the command line.

Building the workspace works, but that doesn't work on the build machine because we don't save/have a workspace in the build system.

Offline rgleim

  • Single posting newcomer
  • *
  • Posts: 8
Re: Building project on command line with dependencies
« Reply #9 on: September 14, 2023, 11:40:49 pm »
Looks like what I'm gathering is that you can't build a single project on the command line and have it figure out the dependent projects, and then build those.  Workspace builds work because it has knowledge of all other projects. Command line looks like you need to specify each individual project, in the order you want, to create the final executable.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Building project on command line with dependencies
« Reply #10 on: September 15, 2023, 12:11:08 am »
So, you decided not to try building the workspace. Per wiki it should work.

https://wiki.codeblocks.org/index.php/Code::Blocks_command_line_arguments

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline rgleim

  • Single posting newcomer
  • *
  • Posts: 8
Re: Building project on command line with dependencies
« Reply #11 on: September 15, 2023, 04:42:53 pm »
Looks like what I'm gathering is that you can't build a single project on the command line and have it figure out the dependent projects, and then build those.  Workspace builds work because it has knowledge of all other projects. Command line looks like you need to specify each individual project, in the order you want, to create the final executable.

I found the attached on the code::blocks wiki, but after setting up the external dependencies in the project, it's still not working on the command line.

Building the workspace works, but that doesn't work on the build machine because we don't save/have a workspace in the build system.

I did build the workspace. See bold from my previous posts.