2.0 beta 10 cannot find user contributed library

I could just be doing something wrong, but I have not been successful at various combinations of trying to get this to work.

I am trying to use a set of libraries that I have written, and when I just include the header file: "#include <FSM.h>" I get the compilation error: " Error: 2 UNKNOWN: exit status 1"
If I just copy and paste the header file inline into the beginning of the .ino file, it successfully compiles.

I tried sketch -> include Library -> Contributed Libraries and selected the library. The header statement is pasted into the sketch, but compilation has the same issue.

I tried changing the location of the header file to the "data" folder under the sketch location, and to the "libraries" folder for the project in the folder above the .ino file, and I still get the same issue.

I also tried "add file" and that also did not work. It did add the folder for FSM.h, and FSM.cpp to the Explorer window, which I can open into a tab.

here is the output of doing "verify"

Detecting libraries used...
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "C:\\Users\\evan\\AppData\\Local\\Temp\\arduino-sketch-0DF552F4042CD265F1D1AE21DF33E309\\sketch\\arduino_Spindle_program.ino.cpp" -o nul
Alternatives for FSM.h: []
ResolveLibrary(FSM.h)
  -> candidates: []
Compilation error: Error: 2 UNKNOWN: exit status 1

If I open and close the IDE... same issue.

I uninstalled the IDE deleted the remaining Arduino files in the c:/users path, rebooted the computer, and then re-installed the Arduino IDE 2.0 and had the same issue.

That's all Sketch -> Include Library does. It's just a convenience feature to add the necessary #include directives to your sketch for a given library. It doesn't do anything else.

That won't work. From the Arduino sketch specification:
https://arduino.github.io/arduino-cli/latest/sketch-specification/#data-subfolder

The data folder is used to add additional files to the sketch, which will not be compiled.

You're at least getting closer. Libraries must be installed to the libraries subfolder of the sketchbook folder. You can learn how to do a manual installation of a library here:
https://www.arduino.cc/en/Guide/Libraries#manual-installation
Give it a try and then let me know if you have any problems.

Ok, I copied the files into the directories:

Sketchbook location: (under file -> preferences)
f:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller

header file location:
F:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\FSM.h

Library file location:
F:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\FSM.cpp

I then closed the IDE and restarted it.
The library shows up in Sketch-> Include Library under "Contributed Libraries"

If I copy inline the header into the .ino file it compiles without issue. If I include it with
#include <FSM.h> it has the following error:

Using board 'mega' from platform in folder: C:\Users\evan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Using core 'arduino' from platform in folder: C:\Users\evan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Detecting libraries used...
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "C:\\Users\\evan\\AppData\\Local\\Temp\\arduino-sketch-0232EEA6C455D494983E7C8CA1928504\\sketch\\Spindle_program.ino.cpp" -o nul
Alternatives for LiquidCrystal_I2C.h: [LiquidCrystal_I2C@1.1.1]
ResolveLibrary(LiquidCrystal_I2C.h)
  -> candidates: [LiquidCrystal_I2C@1.1.1]
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "C:\\Users\\evan\\AppData\\Local\\Temp\\arduino-sketch-0232EEA6C455D494983E7C8CA1928504\\sketch\\Spindle_program.ino.cpp" -o nul
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
  -> candidates: [Wire@1.0]
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "C:\\Users\\evan\\AppData\\Local\\Temp\\arduino-sketch-0232EEA6C455D494983E7C8CA1928504\\sketch\\Spindle_program.ino.cpp" -o nul
Alternatives for FSM.h: [FSM]
ResolveLibrary(FSM.h)
  -> candidates: [FSM]
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM" "C:\\Users\\evan\\AppData\\Local\\Temp\\arduino-sketch-0232EEA6C455D494983E7C8CA1928504\\sketch\\Spindle_program.ino.cpp" -o nul
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM" "f:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C\\LiquidCrystal_I2C.cpp" -o nul
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM" "C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src\\Wire.cpp" -o nul
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM" "C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src\\utility\\twi.c" -o nul
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM" "f:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM\\FSM.cpp" -o nul
Alternatives for ../FSM_Lib/FSM.h: []
ResolveLibrary(../FSM_Lib/FSM.h)
  -> candidates: []
Using library LiquidCrystal_I2C at version 1.1.1 in folder: f:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\LiquidCrystal_I2C 
Using library Wire at version 1.0 in folder: C:\Users\evan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\Wire 
Using library FSM in folder: f:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\FSM (legacy)
Compilation error: Error: 2 UNKNOWN: exit status 1

Note that the library that works "LiquidCrystal_I2C" was installed through the Library manager and is located in the following path (next to FSM):
F:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\LiquidCrystal_I2C

Here is the header file.. just in case there is a difference when it is included:

/*
 * FMS.h
 * The header for the finite state machine
 *  Created on: Jul 5, 2021
 *      Author: evan
 */

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef ARDUINO
	#include <sys/time.h>
#else
	#include <time.h>
#endif

#ifndef FSM_H_
#define FSM_H_

/******************* Actions *****************************/
#define MAX_ACTIONS	6		// The maximum number of actions in an event -1
#define MAX_EVENTS	5		// the maximum number of events for a state
#define MAX_STATES	10		// The maximum number of states in the state machine.
#define MAX_INPUTS 	60		// THE MAXIMUM NUMBER OF INPUTS
#define MAX_OUTPUTS	60		// THE MAXIMUM NUMBER OF INPUTS

//#define TRUE  1
//#define FALSE  0



/******************* Structure Definitions *****************************/

struct pins{
	int pin_Number ;				// the pin number
	bool value ;					// the digital value of the pin
	bool digital_pin ;				// when true this is a digital pin, when false it is an analog pin.
	int a_value;					// the 8 bit analog value for the pin. (A/D)
};


struct userVariables	{
	struct pins inputs[MAX_INPUTS];			// the input signals
	struct pins outputs[MAX_OUTPUTS];		// the output signals
	unsigned int input_list[MAX_INPUTS];	// a list of all the active pins. a pin value of -1 indicates the end of the list.
	unsigned int output_list[MAX_INPUTS];	// a list of all the active pins. a pin value of -1 indicates the end of the list.
	int speed ;								// the desired speed setting for the spindle
	int current_speed;						// the speed that the spindle has been programmed to.
	bool pingState;							// the previous value of the ping IO
	float spindle_temp;						// the temperature for the spindle.
};

struct event_struct{
	int 	next_state = -1;									// The state to transition to after the event is triggered.
	bool 	action_active;										// true when actions are active
	bool 	event_error;
	bool 	(*event_detction)(struct sm_struct *sm);			// pointer to the function that checks if it should be triggered.
	bool 	(*Action_Array[MAX_ACTIONS])(struct sm_struct *sm); // array of actions associated with this event (pointers to functions)
	char	name[100];											// name of the event


};// end event struct definition

struct state_struct{  								// a structure for each state in the state machine
	int (*one_time_function)(struct sm_struct sm);	// function pointer for the one time code
	int (*repeated_execution)(struct sm_struct sm);// function pointer for repeated execution
	struct 		event_struct events[MAX_EVENTS]; 	// array of structures associated with the states
	unsigned long stop_time;						// a second timer used to indicate a valid time function for the state. All timers are reset upon entering the state
	unsigned long watchdog_time;					// a second timer used to indicate the maximum time the SM can remain in the current state, at which time an error is triggered.  0 = disabled
	unsigned int number;							// the state number
	char 		name[100];							// the name of the state
	bool 		first_time_exec = true;				// True when this is executed for the first time.  Reset when exiting the state.

}; // end state_struct



struct sm_struct {  								// state machine structure
	int current_state;
	struct state_struct state_ar[MAX_STATES];		// the array of all of the different states
	struct userVariables userVar;					// the user variables for this state machine
	bool executing_event;

	unsigned long start_time;						// the time at the start of the program in seconds.
	unsigned long current_time;						// the current time in seconds since the start of the program


	void (*io_function)();							// pointer to the IO functions

	// variables for testing
	int executed_actions[MAX_ACTIONS];				// the actions executed in the last event.
	int action_number;								// the action being executed or just executed

	char msg_buffer[200];							// a message buffer used for logging.

}; // end state machine structure


struct test_struct_input{  							// a structure used for testing the finite state machine
	int state =-1;
	int input_pins[2][ MAX_INPUTS];					// the pins to be set for the test [pin_number][value]  a pin number of -1 indicates the end of the list.
	int speed = 0;									// the measured speed
	float temperature;								// the temperature of the spindle
	bool pingstate;									// the value of the ping from the PLC
	bool timeout_triggered;							// if the timer has been triggered for watchdog or other timed events

};

struct test_struct_output{  						// test structure that holds the outputs / results of a unit test
	int output_pins[2][MAX_OUTPUTS]; 				// the pins to be read out after the test [pin_number][value]  a pin number of -1 indicates the end of the list.
	int speed = -1;
	int state = -1;
	bool pingstate = false;
	int test_fail_num = 0;
	int executed_actions[MAX_ACTIONS];				// the actions executed in the last event.
	char expected_event_name[50];					// the name of the expected event to be triggered
};


/******************* General state machine functions *****************************/
void SM_run(struct sm_struct *sm);							// The function that runs the state machine

void log_message(struct sm_struct *sm );							// output a message
int  FSM_Test(struct sm_struct *sm, struct test_struct_input *input, struct test_struct_output *output);
void load_input_pins(int pin_List1[MAX_INPUTS][2], struct test_struct_input *input);
void load_output_pins(int pin_List1[MAX_OUTPUTS][2], struct test_struct_output *output);
void load_executed_actions(struct test_struct_output *output, int A1, int A2, int A3, int A4 , int A5);
unsigned long get_time(struct sm_struct *sm);
bool watchdog_event(struct sm_struct *sm);

void init_event(											// This function takes a list of variables that make up the full definition for the event and fills the event structure.
		struct sm_struct *sm,								// The event structure to be initialized
		int state_num,										// the state integer
		int event_num,										// the event number in the array of events 0 - n
		char *name,											// The name of the event
		int next_state,										// The next state if this event is tripped.
		bool (*event_detction_ptr)(struct sm_struct*),		// A pointer to the function that checks if this event has been tripped. (returns T/F)
		bool (*action1)(struct sm_struct* ),				// A pointer to the first action to take
		bool (*action2)(struct sm_struct* ),				// A pointer to the second action to take
		bool (*action3)(struct sm_struct* ),				// A pointer to the third action to take
		bool (*action4)(struct sm_struct* ),				// A pointer to the fourth action to take
		bool (*action5)(struct sm_struct* )					// A pointer to the fifth action to take
		);
/********************************************************************/
/********************************************************************/

#ifndef ARDUINO   											// if Arduino not defined then put in dummy functions to prevent errors
	bool digitalRead(int pin);
	int analogRead(int pin);
	void digitalWrite(int pin, bool value);
	void analogWrite(int pin, int value);

#endif 														// if Arduino not defined then put in a dummy

#endif /* FSM_H_ */

I replied to the original message.. Still no dice.

Have you tried to create you code as a library?

i.e. in Arduino/libraries add a folder with your name (or any name you like) and put your code in it.

Do you mean: Arduino_Project_Directory/libraries/mylib/mylib.h ?
Or do you mean something else ?

Here is what it looks like:

Here is the library selection

This is incorrect. An Arduino library is a folder. That library folder must be installed under the libraries subfolder of the sketchbook folder.

So it would look something like this

<sketchbook folder>
|_ libraries
   |_ FSM
      |_ FSM.h
      |_ <other library files...>

There is an alternative "recursive" library format that is actually more common than the "legacy" format shown above:

<sketchbook folder>
|_ libraries
   |_ FSM
      |_ library.properties
      |_ src
         |_ FSM.h
         |_ <other library source files...>

Either format is likely fine for your application of a manual installation. I just didn't want you to be confused if you saw the different structure of some other recursive library you had installed.

Your #include directive is wrong. Change it to this:

#include <FSM.h>

The Arduino build system automatically discovers the library that contains the header file and compiles it. You should not specify the path to the file in your #include directive.

Thank you for the clear feedback. I am still a bit confused in your comments on the #include though. If you look at the first jpg, the include statement is as you suggest

#include <FSM.h>

You can also see the file structure in the first jpg in the explorer window. It looks like I messed up the path when I copied and pasted it into the post. I believe it is also as you suggest.

under the libraries folder there are three sub folders

  • FSM
  • LiquidCrystal_I2C
  • Finite_State_machine

Inside the FSM folder are the files

  • FSM.h
  • FSM.cpp

With this file structure I get this error, and it is making some really odd "Alternatives" ../FSM_Lib/FSM.h . It seems like it is not finding something that it expected in the first place.

Alternatives for ../FSM_Lib/FSM.h: []
ResolveLibrary(../FSM_Lib/FSM.h)
  -> candidates: []
Using library LiquidCrystal_I2C at version 1.1.1 in folder: f:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\LiquidCrystal_I2C 
Using library Wire at version 1.0 in folder: C:\Users\evan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\Wire 
Using library FSM in folder: f:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\FSM (legacy)
Compilation error: Error: 2 UNKNOWN: exit status 1

I tried the recursive format you suggest:

  • Add a library.properties file (I modified the one from the LiquidCrystal I2C library
  • Add a src folder, and place the .h and .cpp files.

Unfortunately the result was pretty similar.

Alternatives for FSM.h: [FSM@1.0]
ResolveLibrary(FSM.h)
  -> candidates: [FSM@1.0]
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM\\src" "C:\\Users\\evan\\AppData\\Local\\Temp\\arduino-sketch-0232EEA6C455D494983E7C8CA1928504\\sketch\\Spindle_program.ino.cpp" -o nul
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM\\src" "f:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C\\LiquidCrystal_I2C.cpp" -o nul
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM\\src" "C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src\\Wire.cpp" -o nul
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM\\src" "C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src\\utility\\twi.c" -o nul
"C:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\mega" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\LiquidCrystal_I2C" "-IC:\\Users\\evan\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\Wire\\src" "-If:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM\\src" "f:\\Evan\\projects\\arduino\\mega_shiled_for_CNC_router\\software\\arduino-ATC-spindle-controller\\libraries\\FSM\\src\\FSM.cpp" -o nul
Alternatives for ../FSM_Lib/FSM.h: []
ResolveLibrary(../FSM_Lib/FSM.h)
  -> candidates: []
Using library LiquidCrystal_I2C at version 1.1.1 in folder: f:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\LiquidCrystal_I2C 
Using library Wire at version 1.0 in folder: C:\Users\evan\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\Wire 
Using library FSM at version 1.0 in folder: f:\Evan\projects\arduino\mega_shiled_for_CNC_router\software\arduino-ATC-spindle-controller\libraries\FSM 
Compilation error: Error: 2 UNKNOWN: exit status 1

new directory structure

Here is the library.properties file.

name=FSM
version=1.0
author=Evan
maintainer=Evan
sentence=A library for arbitrary Finite State Machines
paragraph= The library provides a base structure for the Finite state machine.  It is meant to be paired with a user defined library that defines the specific events, actions, and transitions. 
category=Structure
url=https://github.com/mccartes/arduino-ATC-spindle-controller
architectures=avr

You most likely have a line like this somewhere in your code:

#include "../FSM_Lib/FSM.h"

That could be in one of the library files if not in the sketch (check FSM.cpp).

The classic Arduino IDE provides better output when there is this sort of problem. The Arduino IDE 2.x is in the beta development phase and I think you will be better off to use the classic Arduino IDE for standard usage, using 2.x for when you want to participate in the development effort via beta testing.

The alternatives are []. This signifies an empty array, meaning that no libraries were found by the library discovery process to match that #include directive.

Nice! It's a little extra work to add the library.properties file, but it's really nice to have some metadata for the library. This is also required if you decide you want to add your library to the Arduino Library Manager.

Thank you so much for the help.

#include "../FSM_Lib/FSM.h"

Was in the FSM.cpp , and once this was fixed then I was able to get it to compile.

For anyone else using Arduino functions in a library, you need to add #include <Arduino.h> in order to use functions like millis() in the library. Otherwise you get the error:

error: 'millis' was not declared in this scope  

You're welcome. I'm glad it's working now!
Regards, in0

I have an update regarding the user unfriendly format of this error:

It was the result of a bug in the Arduino CLI tool Arduino IDE 2.x uses under the hood for compiling sketches. That bug has now been fixed:

That fix is not yet in Arduino IDE 2.x, but it will be in one of the upcoming releases.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.