I've this error that I receive when I try to compile:
Linking CXX executable /home/atv/catkin_ws/devel/lib/atvAcrosser/main**
CMakeFiles/main.dir/src/sendToCAN.cpp.o: In function `sendCAN()':
sendToCAN.cpp:(.text+0x432): undefined reference to `sendCanMessage(CanMsg*)'
collect2: ld returned 1 exit status
make[2]: *** [/home/atv/catkin_ws/devel/lib/atvAcrosser/main] Error 1
make[1]: *** [atvAcrosser/CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
Main call the thread sendCAN [inside sendToCAN.cpp] who calls the function sendCanMessage in the external library libARV6005.a.
This is the CMakeList.txt:
include_directories(include ${catkin_INCLUDE_DIRS})
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/atvAcrosser/lib/)
add_executable(main src/main.cpp src/setupPacketProtocol.cpp src/sendToCAN.cpp)
target_link_libraries(main ${catkin_LIBRARIES} ARV6005)
This is the tree:
src
├── atvAcrosser
│ ├── CMakeLists.txt
│ ├── include
│ │ └── atvAcrosser
│ │ ├── ARV6005Lib.h
│ │ ├── localPlannerCommunication.h
│ │ ├── receiveFromCAN.h
│ │ └── setupPacketProtocol.h
│ ├── lib
│ │ └── libARV6005.a
│ ├── package.xml
│ ├── src
│ │ ├── localPlannerCommunication.cpp
│ │ ├── main.cpp
│ │ ├── sendToCAN.cpp
│ │ ├── setupPacketProtocol.cpp
sendToCAN.h
// included dependencies
#include "ARV6005Lib.h"
//=================================
// function
void sendCAN();
sendToCAN.cpp
#include "../include/atvAcrosser/sendToCAN.h"
...
void sendCAN()
{
struct CanMsg msg;
struct CanMsg msg;
int i, result;
memset((void *)&msg, 0, sizeof msg);
msg.id = 0x33;
msg.id_type = STD_ID;
msg.length = 8;
for(i=0; i<8; i++) {
msg.data[i] = i;
}
result = sendCanMessage(&msg);
}
but with this Makefile in a tutorial example it works
all: main.c
gcc -w -o TestUtility -D_REENTRANT -I../Library -pthread ./main.c ./libARV6005.a
Check that sendCanMessage(CanMsg*) is declared in ARV6005Lib.h
Check that libARV6005.a contains symbol sendCanMessage
If symbol sendCanMessage is not in libARV6005.a, find where it is and link your executable with it.
Run make VERBOSE=1, extract link command and post it here
In your CMakeLists.txt you are missing _REENTRANT and pthread. Use target_compile_definitions and target_link_libraries to add it.
The ARV6005Lib.a was written in C.
The sendToCAN.cpp has been written in Cpp.
So was sufficient
edit the file that include ARV6005Lib.h:
extern "C" {
#include "../include/atvAcrosser/ARV6005Lib.h"
}
Related
If I have the following:
├── Cargo.lock
├── Cargo.toml
├── main
│ ├── Cargo.toml
│ └── src
│ └── main.rs
├── module2
│ ├── Cargo.toml
│ └── src
│ ├── lib.rs
│ └── builder.rs
Where the Cargo.toml file in the root is the following:
[workspace]
members = [
"main",
]
I want to access a function from builder.rs in main when testing(i.e. cfg(test)), how can I do so?
Module2 is a library(it was created by running cargo new module2 --lib.
I tried the following:
// module2/builder.rs
pub fn build() { /*...*/ }
// module2/lib.rs
#[cfg(test)]
mod mock;
#[cfg(test)]
pub use mock::build;
// main/Cargo.toml
// ...
[dependencies]
module2 = { path = "../module2" }
// main.rs
#[cfg(test)]
use module2::build;
/*
...
*/
This doesn't work and I get the following error:
error[E0432]: unresolved import `module2::build`
--> main/src/main.rs:3:5
|
3 | use module2::build;
| ^^^^^^^^^^^^^^ no `build` in the root
test of module1 is not test of main: each crate gets cfg(test) turned on only when it itself is being tested, not when a dependency of it is being tested.
You can use cfg(debug_assertions) as an approximation or a custom feature.
I need your help because this is really starting to get to me.
I can't seem to solve this error with TypeORM and NestJS.
ERROR [ExceptionHandler] No repository for "CommentRepository" was
found. Looks like this entity is not registered in current "default"
connection?
The error is pretty clear but I don't understand how the config entities: [] works.
The worst thing is that before, everything was working perfectly. But after a little refactoring of my structure, it doesn't work anymore.
My folder structure :
.
├── app.module.ts
├── authentication
│ ├── auth.controller.ts
│ ├── auth.module.ts
│ ├── auth.service.ts
│ ├── dto
│ └── enums
├── common
│ ├── constants
│ ├── decorators
│ ├── enums
│ ├── exceptions
│ ├── guard
│ ├── helpers
│ ├── interceptor
│ ├── interfaces
│ ├── middlewares
│ ├── pipes
│ ├── serializers
│ ├── strategies
│ └── validations
├── config
│ ├── app
│ ├── cache
│ └── database # Here are my database config
├── database
│ ├── config.schema.ts
│ ├── factories
│ ├── migrations
│ ├── providers
│ └── seeders
├── locales
│ ├── en
│ └── fr
├── mails
│ ├── mail.module.ts
│ ├── mail.service.ts
│ ├── reset-password
│ ├── templates
│ └── verification
├── main.ts
└── models # Here are my models
├── address
├── booking
├── comment
├── company
├── container
├── listing
├── office
├── port
└── user
My database config :
...
├── config
│ ├── app
│ ├── cache
│ └── database
│ └── postgres
│ ├── config.module.ts
│ ├── config.service.ts
│ └── configuration.ts
...
My database config service and the app module
// config.service.ts
import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '#nestjs/typeorm';
import { Injectable } from '#nestjs/common';
import { ConfigService } from '#nestjs/config';
#Injectable()
export class PostgresConfigService implements TypeOrmOptionsFactory {
constructor(private configService: ConfigService) {}
createTypeOrmOptions(): TypeOrmModuleOptions {
return {
type: 'postgres',
host: this.configService.get<string>('DB_HOST'),
port: this.configService.get<string>('DB_PORT'),
username: this.configService.get<string>('DB_USERNAME'),
password: this.configService.get<string>('DB_PASSWORD'),
database: this.configService.get<string>('DB_DATABASE'),
entities: ['../../models/**/entities/*.entity.{ts,js}'],
synchronize: true,
autoLoadEntities: true,
migrations: ['src/database/migrations/*.ts'],
migrationsRun: true,
cli: {
migrationsDir: 'src/database/migrations',
},
};
console.log(this.configService.get<string>('DB_HOST'));
}
}
// app.module.ts
...
imports: [
ConfigModule.forRoot({
envFilePath: [`.env.${process.env.STAGE}`],
validationSchema: configValidationSchema,
isGlobal: true,
}),
TypeOrmModule.forRootAsync({
useClass: PostgresConfigService,
inject: [PostgresConfigService],
}),
...
]
I have two projects: my-lib a Vue 3 library and my-project a Vue 3 project that uses this library.
My-lib:
I can compile the library and compile its declaration files. This what I have in the dist folder of the library:
./dist
├── demo.html
├── index.common.js
├── index.common.js.map
├── index.umd.js
├── index.umd.js.map
├── index.umd.min.js
├── index.umd.min.js.map
├── src
│ ├── components
│ │ └── book
│ │ ├── BookToolBar.d.ts
│ │ └── BookToolBar.d.ts.map
│ ├── index.common.d.ts
│ ├── index.common.d.ts.map
│ └── shared
│ └── security
│ ├── AuthenticationResult.d.ts
│ └── AuthenticationResult.d.ts.map
└── tsconfig.tsbuildinfo
This is a piece from package.json of the library:
"name": "my-lib",
"version": "0.1.0",
"private": true,
"files": [
"dist/**.*"
],
"main": "dist/index.common.js",
"unpkg": "dist/index.umd.min.js",
"types": "dist/src/index.common.d.ts",
This is a dist/src/index.common.d.ts file:
export { BookToolBar } from "#/components/book/BookToolBar";
export { AuthenticationResult } from "#/shared/security/AuthenticationResult";
My-project:
The problem is that VS code ignores my declaration files in the following code:
import { AuthenticationResult } from "my-lib";
class AuthenticationResultChild extends AuthenticationResult {...}
However, the following code works fine:
import { AuthenticationResult } from "my-lib/dist/src/shared/security/AuthenticationResult";
class AuthenticationResultChild extends AuthenticationResult {...}
Could anyone say, how to make VS code work with declarations using the first variant (import { AuthenticationResult } from "my-lib")?
I am attempting to add a GUI to a small project of mine using Conrod. I have managed to work my way down to 3 compilation errors:
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:88:53
|
88 | pub fn next(&mut self, events_loop: &mut glium::glutin::EventsLoop) -> Vec<glium::glutin::Event> {
| ^^^^^^ Could not find `glutin` in `glium`
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:88:87
|
88 | pub fn next(&mut self, events_loop: &mut glium::glutin::EventsLoop) -> Vec<glium::glutin::Event> {
| ^^^^^^ Could not find `glutin` in `glium`
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:106:24
|
106 | glium::glutin::ControlFlow::Break
| ^^^^^^ Could not find `glutin` in `glium`
I've studied the examples that ship with Conrod (particularly the text_edit.rs example) and have successfully compiled and run them. As far as I can tell, they use the same techniques (as my code is directly inspired by their examples), yet does not suffer from the unresolved imports of glutin.
Furthermore, I cannot seem to find any reference to glutin in the project directory itself:
$> pwd
~/dev/conrod/src
$> tree.
.
├── backend
│ ├── gfx.rs
│ ├── glium.rs
│ ├── mod.rs
│ ├── piston
│ │ ├── draw.rs
│ │ ├── event.rs
│ │ └── mod.rs
│ └── winit.rs
├── border.rs
├── color.rs
├── cursor.rs
├── event.rs
├── graph
│ ├── algo.rs
│ ├── depth_order.rs
│ └── mod.rs
├── guide
│ ├── chapter_1.rs
│ ├── chapter_2.rs
│ └── mod.rs
├── image.rs
├── input
│ ├── global.rs
│ ├── mod.rs
│ ├── state.rs
│ └── widget.rs
├── label.rs
├── lib.rs
├── position
│ ├── matrix.rs
│ ├── mod.rs
│ ├── range.rs
│ └── rect.rs
├── render.rs
├── tests
│ ├── global_input.rs
│ ├── mod.rs
│ ├── ui.rs
│ └── widget_input.rs
├── text.rs
├── theme.rs
├── ui.rs
├── utils.rs
└── widget
├── bordered_rectangle.rs
├── builder.rs
├── button.rs
├── canvas.rs
├── collapsible_area.rs
├── drop_down_list.rs
├── envelope_editor.rs
├── file_navigator
│ ├── directory_view.rs
│ └── mod.rs
├── graph
│ ├── mod.rs
│ └── node.rs
├── grid.rs
├── id.rs
├── list.rs
├── list_select.rs
├── matrix.rs
├── mod.rs
├── number_dialer.rs
├── plot_path.rs
├── primitive
│ ├── image.rs
│ ├── line.rs
│ ├── mod.rs
│ ├── point_path.rs
│ ├── shape
│ │ ├── circle.rs
│ │ ├── mod.rs
│ │ ├── oval.rs
│ │ ├── polygon.rs
│ │ ├── rectangle.rs
│ │ └── triangles.rs
│ └── text.rs
├── range_slider.rs
├── rounded_rectangle.rs
├── scrollbar.rs
├── scroll.rs
├── slider.rs
├── tabs.rs
├── text_box.rs
├── text_edit.rs
├── title_bar.rs
├── toggle.rs
└── xy_pad.rs
For reference, my Cargo.toml also includes glutin as a dependency:
[features]
default = ["winit", "glium"]
winit = ["conrod/winit"]
glium = ["conrod/glium"]
[dependencies]
conrod = "^0.57"
find_folder = "*"
glutin = "*"
I believe this is a misconception about the module structure of conrod and glium.
The conrod crate has a number of backend modules, containing utility functions for each of the different backends. conrod::backend::glium is this module for glium, and it contains structures and things useful for using conrod with glium.
In your case, however, I think you mistook this module for glium itself.
glium is a separate crate from conrod, and you'll need to depend on it much like you depend on glutin. glium does indeed have a glium::conrod property, so if you do pull it in with extern crate glium; rather than using conrod::backend::glium, it should "just work"!
You'll need to add some line glium = 0.x in your Cargo.toml as well, but that should be trivial.
Below are my codes
// config
requirejs.config({
paths: {
jquery: 'library/jquery',
jsBarcode: 'library/jsBarcode.all.min',
q: 'library/q.min',
},
shim: {
jsBarcode: {
deps: ['jquery'],
export: 'JsBarcode',
},
}
});
// Main entry
require(['jquery', 'q', 'jsBarcode'], function (j, q, barcode) {
window.Q = q;
console.log(barcode); // get undefined
});
Directory layout
└── webcontroller
├── bootstrap.min.css
├── image
│ └── load_trans.gif
├── scripts
│ ├── library
│ │ ├── jquery.js
│ │ ├── jsBarcode.all.min.js
│ │ └── q.min.js
│ ├── main.js
│ ├── promise_factory.js
│ ├── require.js
│ └── view.js
└── style.css
Loading sequences
The order for loading scripts is under my expectations.
Problems
However, barcode is undefined all the time.
Any one have ideas about this problem?
Updated
However, below codes can dump something out....
console.log(JsBarcode);
Fix the typo export -> exports, it must be the root cause. Also you have three excessive commas although it seems not to cause troubles. Finally there must be some global JsBarcode defined in jsBarcode.all.min.js that's why your console.log dumps it.
jsBarcode: {
deps: ['jquery'],
exports: 'JsBarcode'
}