compiling error on nano

I am trying to compile a sketch on the nano using the si5351 frequency chip, the libraries are configured correctly as I have compiled another sketch using the same chip and library. I tried all the available libraries for the chip but only one worked for the other sketch that compiled, and this one goes all the way until it errors out at linking everything. I am at wits end trying to figure out how to correct this, I am not a programmer, but have used many different arduinos, and usually muddle through and find the reason for error. Attached is the error and sketch, any help would be appreciated. I have the si5351.h file in the sketch folder, the same way I did when I compiled the other sketch with no problems, and made sure no other libraries for the si5351 was in the arduino library. Thank you for any help given.

error 5351.txt (55.1 KB)

sketch_jul24c.ino (16.7 KB)

Sorry about attaching the files instead of using "code". Next time I will make sure I post correctly.

It looks like you only copied the header files of the si5351 library. Where did you get it, and where did you put it?


PieterP, The header file was included with the other sketch I used and compiled, and has the si5351.cpp file included in it. I put it in the program sketch folder, using "#include si5351.h" in the sketch. It works very well with the other sketch which is a lot larger. I also tried all other libraries for the si5351 chip adafruit, etherkit, and the si5351 library from the mfg. The others would not get very far in compiling, and I don't know enough to understand why. This sketch is a simple frequency vfo, the one that compiled was a vector analyzer, vfo, and more. All the libraries used are the same for both sketches.

Are you sure that the si5351.cpp file is in the same folder? Use CTRL+K (show sketch folter IIRC) to verify.

Yes, I just checked again.

Do you know how the compilation process works?

The compiler compiles each implementation file (.ino or .cpp) separately. When compiling your ino file, it just looks if the functions you're using can be found in the header files (.h). The compiler doesn't need to have the implementation of these functions available, just their name.
Then the implementations of the functions should be compiled. This happens completely separately from your sketch.
The final step is to link the compiled (object) file of your ino file to the compiled object file of the library.
That's where the linker fills in the gaps and stitches everything together: it links the names of external functions to the actual implementations.
In your case, the linker cannot find these implementations, because they were not compiled.

If you check the build output you posted, you'll find that the si5351.cpp file was indeed never compiled. Either because it's in the wrong folder, or because of a bug in the Arduino builder. The latter is not very likely.

Please post a directory listing or screenshot of the folder contents of C:\Users\johnr\Documents\Arduino\sketch_jul24c. If posting an image, please follow this guide to embed it in your post:

Here is the directory snap. I was busy changing the library to <Adafruit_SI5351.h>, and also including the.cpp in the sketch too, it points to the arduino library as shown above. I get an error of "does not name a type" with the adafruit library. The error has to be in the sketch, but where and what?

PieterP, I made sure the header and .cpp file was in the sketch folder, only thing I wasn't sure of was if I should include the cpp file in the sketch itself, but I did that and no soap, so I commented it out. I tried all three libraries, with only one in the library directory at a time of course, making sure the name of the header file, in the library, was what was in the sketch. Each library gave a different error when compiling. The header file used to compile the other sketch came from "Copyright (C) 2015-2016 Jason Milldrum". The sketch compiled with just the header file. I understand the basics of the arduino ide, but am no expert in any way.

Sorry about attaching the files instead of using "code". Next time I will make sure I post correctly.

No need; your files are too big so we have to live with attachments :wink: There is a 9000 character limit for a post.

Can you provide a link to the library that you're using?

(the adafruit and etherkit libraries can be installed with the library manager, here are 2 sources that are supposed to be updated. Also the other sketch that does compile, the origional author said he included the cpp file for the si5351 into the sketch itself. Which explains why it compiles without the cpp file.

Also the library he used was the Ethrtkit library. Hope that helps.

You've lost me.

If you need an Arduino library, install it correctly.

If you use functions from a header file, the linker needs the compiled versions of the implementations of those functions, so you have to have the implementations: either inline in the header file, or in a separate implementation file (cpp, cxx, cc, c++).
If your cpp files are in the same folder as your ino file, the Arduino builder will compile these files for you, and link them into the final executable.

You should never #include a cpp file. Each cpp file is a separate translation unit.
The only case where you include implementation files is when you're dealing with template functions/classes. In that case, you can move the template definitions to a separate ipp file, that you include at the bottom of your header.

When I compile your code (after downloading the latest versions of the libraries that you mentioned using the library manager), it indeed complains about the init method (and a few others). Note that the libraries are installed in their default location, not in the sketch directory).

The init method in the library expects 3 arguments, you only provide 2. The prototype in si5351.h

	bool init(uint8_t, uint32_t, int32_t);

I suspect that the source that you based your code on makes use of older versions or is just a crappy source, but I leave it up to you to find that out.

I had to remove Rotary as I don't know which one you installed (there are a few when I search using library manager) and I used a standard LCD library as I don't know which specific one you use.

Sterretje, I used the Etherkit_si5351 library, lcd was standard from C:program files x86/ arduino/libraries/ liquidcrystal, encoder is by paul stroffregen available in library manager. I had tried both ways for header and cpp files for the si5351, in the sketch folder itself, and in the default folder in documents/arduino/libraries/, trying to eliminate possible library problems. I have the sketch now compiled and running and the biggest culprit was in the sketch, the entries for "si5351.set_freq((vfo * SI5351_FREQ_MULT), SI5351_PLL_FIXED, SI5351_CLK0);" were all wrong as an update had been made in the header and cpp files to make it easier to use. I scoured everywhere on the errors before finally learning about the update change. Removing the "SI5351_PLL_FIXED" from each instance in the sketch cured the problem, there were a couple syntax mistakes to correct probably caused when the sketch was copied. I try to use only the libraries installed in the default documents/arduino folder, but sometimes it was necessary to put the header and cpp files in the sketch folder. I do learn a lot from my mistakes, and also from sketches from others too. Thanks for the help from everyone, really appreciate it.