I have a library Foo.sol in /logicalroot/src/main/sol/lib/Foo.sol

I have a contract MyContract in /logicalroot/src/main/sol/contracts/MyContract.sol That contract sources this:

import {Foo} from "Foo.sol";

Executing from /logicalroot

solc-static-linux-0.7.0 --abi --bin --overwrite -o build/main src/main/sol/contracts/MyContract.sol

I cannot get solc to find the import despite many permutations of command line args and import decs, e.g.:

import {Foo} from "Foo.sol";
import {Foo} from "./Foo.sol";
import {Foo} from "/Foo.sol";
import {Foo} from "../lib/Foo.sol";

and all manner of --allow-paths and --base-path setups. The only way I can get it to run is with Foo.sol copied into the same dir as MyControl.sol and no command line --allow-paths or --base-path args and the import being:

import {Foo} from "./Foo.sol";  // NOTICE the dot slash path!

Then it works perfectly fine! But not even a symlink works, e.g.

$ cd contracts
$ ln -s ../lib/Foo.sol .

Is this a solc 0.7.0 issue perhaps? Any clues for an old-time C #include "file.h" guy would be much appreciated.

1 Answer 1


I got the same problem, the only workaround I have found is to pass the ..=.. argument to solc, so it will correctly interpret the paths.

So my layout is:

├── artifacts
├── contr
│   └── A.sol
└── somedir
    └── B.sol


import "../somedir/B.sol";

And I run solc from the root dir in the following way:

solc --abi --bin contr/A.sol -o artifacts --overwrite ..=..
  • Yikes -- but yes that works. Commented Aug 24, 2021 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.