Author Topic: ar.exe: obj\Debug\main.o: No such file or directory  (Read 2399 times)

Offline creativegamer_03

  • Single posting newcomer
  • *
  • Posts: 8
  • </CG03>
ar.exe: obj\Debug\main.o: No such file or directory
« on: September 03, 2021, 03:02:21 pm »
Trying to build a static library from the jsoncpp library (amalgamated version) so I can link it with my main project that uses it (but errors due to multiple "undefined references" from the library). However, it errored to (including full log):
Code
-------------- Build: Debug in jsoncpp (compiler: GNU GCC Compiler)---------------

WARNING: Can't read file's timestamp: D:\_a\jsoncpp\main.c
cmd /c if exist bin\Debug\libjsoncpp.a del bin\Debug\libjsoncpp.a
ar.exe -r -s bin\Debug\libjsoncpp.a obj\Debug\main.o
ar.exe: creating bin\Debug\libjsoncpp.a
ar.exe: obj\Debug\main.o: No such file or directory
Process terminated with status 1 (0 minute(s), 1 second(s))
1 error(s), 1 warning(s) (0 minute(s), 1 second(s))

When I was creating the project via the wizard, I changed no options other than name of the project. Is there something I missed or is there something wrong?
{"c":['creative', 'coder'],
"g":"gamer",
"n":03
"forum":"codeblocks"}

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 826
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #1 on: September 03, 2021, 06:53:09 pm »
Does D:\_a\jsoncpp\main.c exist? Can you remove the underscore from the path and try again?

Offline creativegamer_03

  • Single posting newcomer
  • *
  • Posts: 8
  • </CG03>
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #2 on: September 04, 2021, 05:59:09 am »
Well, that's the actual folder's name ("_a") since I want it above other folders when I access D:\. Anyways, should it be a .c file and not a .cpp file? The JsonCPP library is in .cpp source file format, with some header files in a separate folder in it.

File hierarchy of jsoncpp (amalgamated):
Code
./
|
---- jsoncpp
      |
      ---- json.h
      ---- json-forwards.h
|
---- jsoncpp.cpp
{"c":['creative', 'coder'],
"g":"gamer",
"n":03
"forum":"codeblocks"}

Online Commaster

  • Almost regular
  • **
  • Posts: 129
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #3 on: September 04, 2021, 06:45:07 am »
So it's not D:\_a\jsoncpp\main.c but D:\_a\jsoncpp.cpp

Offline creativegamer_03

  • Single posting newcomer
  • *
  • Posts: 8
  • </CG03>
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #4 on: September 04, 2021, 11:06:16 am »
Oops. Sorry to confuse you about the path. The full path is actually D:\_a\jsoncpp\jsoncpp.cpp.
What I meant there is the projects folder being named "_a". I forgot to mention that "jsoncpp" is under that folder, of which this folder was created by Code::Blocks from the wizard.
{"c":['creative', 'coder'],
"g":"gamer",
"n":03
"forum":"codeblocks"}

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 826
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #5 on: September 04, 2021, 01:23:26 pm »
You must remove main.c from the project and add jsoncpp.cpp. Probably main.c is the default file created by the wizard, and it is not necessary.

Offline creativegamer_03

  • Single posting newcomer
  • *
  • Posts: 8
  • </CG03>
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #6 on: September 04, 2021, 01:40:49 pm »
You must remove main.c from the project and add jsoncpp.cpp. Probably main.c is the default file created by the wizard, and it is not necessary.
I just did. I did replace it, as well as copying in also the jsoncpp folder containing its header files.
{"c":['creative', 'coder'],
"g":"gamer",
"n":03
"forum":"codeblocks"}

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 826
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #7 on: September 04, 2021, 01:50:01 pm »
Does it work now?

Offline creativegamer_03

  • Single posting newcomer
  • *
  • Posts: 8
  • </CG03>
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #8 on: September 04, 2021, 04:06:43 pm »
nope. same thing.
{"c":['creative', 'coder'],
"g":"gamer",
"n":03
"forum":"codeblocks"}

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 826
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #9 on: September 04, 2021, 06:13:46 pm »
The log must be different, please post it.

Offline creativegamer_03

  • Single posting newcomer
  • *
  • Posts: 8
  • </CG03>
Re: ar.exe: obj\Debug\main.o: No such file or directory
« Reply #10 on: September 05, 2021, 04:55:27 am »
The log was the same as the first post. However I just solved my problem.

So, I was quite curious what the .cbp file looks like inside, which I then found out to be in an XML format. Looking through the tags, I found the tag '<Unit filename="main.c">'. I tinkered it by replacing it with "jsoncpp.cpp".
At first, I thought it didn't do anything when I try to rebuild it.
Then I thought of relaunching Code::Blocks and open the project file afterwards to load up from the modded .cbp file.
And so I did, then opened the "jsoncpp.cpp" file, pressed F9, and it is fixed.
{"c":['creative', 'coder'],
"g":"gamer",
"n":03
"forum":"codeblocks"}