Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading an "extern mod" multiple times in separate files will throw error "Library 'X' already added" #5951

Closed
dymk opened this issue Apr 19, 2013 · 1 comment
Labels
A-linkage Area: linking into static, shared libraries and binaries

Comments

@dymk
Copy link

dymk commented Apr 19, 2013

Lets say you've got an extern module called 'X':

#[link_name = "MY_LIBRARY_LINK_NAME"]
#[link_args="-L/path/to/your/library/x"]
pub extern mod X {
    fn foo();
}

And files A, B, and C (lets say they define tests, or something), in a structure something like this:

/ -> 
    test ->
        a.rs
        b.rs
        c.rs
    lib ->
        x.rs

If one was to define B and C like so to load module X:

b.rs:

#[path = '../lib/x.rs']
mod x;

//and some test functions

c.rs:

#[path = '../lib/x.rs']
mod x;

//and some test functions

And then include both in 'a.rs'
a.rs:

mod a;
mod b;

The compiler would throw an error such as:
x.rs:0:0: 0:1 error: library 'MY_LIBRARY_LINK_NAME' already added: can't specify link_args.

@thestinger
Copy link
Contributor

The extern mod statement is gone, so I don't think this is a problem anymore.

flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 28, 2020
…roto

Fix incorrect suggestion when `clone_on_ref_ptr` is triggered in macros

In the lint `clone_on_ref_ptr`, if the `span` is in a macro, don't expand it for suggestion.

Fixes: rust-lang#2076

changelog: none

r? @ebroto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries
Projects
None yet
Development

No branches or pull requests

2 participants